Repository: gin-gonic/gin
Pull request #2803 (2021-08-03 09:16:02)

fix(engine): missing route params for CreateTestContext (#2778)
This PR trying to fix the issue we met, which exact same with https://github.com/gin-gonic/gin/issues/2778

If you guys have better idea to fix this, just let me know.



codecov[bot]: # [Codecov](https://codecov.io/gh/gin-gonic/gin/pull/2803?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gin-gonic) Report
> Merging [#2803](https://codecov.io/gh/gin-gonic/gin/pull/2803?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gin-gonic) (9db2b15) into [master](https://codecov.io/gh/gin-gonic/gin/commit/6ebb945bd7ac10b0fec87299129b6d9603e1e4ab?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gin-gonic) (6ebb945) will **increase** coverage by `0.00%`.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/gin-gonic/gin/pull/2803/graphs/tree.svg?width=650&height=150&src=pr&token=Qpqxhwery8&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gin-gonic)](https://codecov.io/gh/gin-gonic/gin/pull/2803?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gin-gonic)

```diff
@@           Coverage Diff           @@
##           master    #2803   +/-   ##
=======================================
  Coverage   98.71%   98.71%           
=======================================
  Files          41       41           
  Lines        2100     2104    +4     
=======================================
+ Hits         2073     2077    +4     
  Misses         15       15           
  Partials       12       12           
```


| [Impacted Files](https://codecov.io/gh/gin-gonic/gin/pull/2803?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gin-gonic) | Coverage Δ | |
|---|---|---|
| [gin.go](https://codecov.io/gh/gin-gonic/gin/pull/2803/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gin-gonic#diff-Z2luLmdv) | `99.18% <100.00%> (ø)` | |
| [test\_helpers.go](https://codecov.io/gh/gin-gonic/gin/pull/2803/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gin-gonic#diff-dGVzdF9oZWxwZXJzLmdv) | `100.00% <100.00%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/gin-gonic/gin/pull/2803?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gin-gonic).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gin-gonic)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/gin-gonic/gin/pull/2803?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gin-gonic). Last update [6ebb945...9db2b15](https://codecov.io/gh/gin-gonic/gin/pull/2803?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gin-gonic). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=gin-gonic).

shrike42: Had the same problem when trying to follow the examples. 

The fix you outline would work but I think at that point especially with the need to create a separate engine to get the valid maxParam value one could just use a different approach using ServeHTTP and forget CreateTestContext.

Tests could be written as follows based on your example:

	w := httptest.NewRecorder()
	engine := New()

        // At this point add the route(s) to test
	engine.GET("/:action/:name", func(ctx *Context) {
		ctx.String(http.StatusOK, "%s %s", ctx.Param("action"), ctx.Param("name"))
	})
	
        r = http.NewRequest(http.MethodGet, "/hello/gin", nil)
	
        engine.ServeHTTP(w,r)

	assert.Equal(t, http.StatusOK, w.Code)
	assert.Equal(t, "hello gin", w.Body.String())

Admittedly this does not use the test context at all but I wonder if using CreateTestContext is even a good idea one could say that ServeHTTP is a better approach. Like the context method this does not start the engine.
appleboy: @RoCry Please fix the conflicts.

Patch:
diff --git a/.github/workflows/gin.yml b/.github/workflows/gin.yml
index 6dc787a..18b36d0 100644
--- a/.github/workflows/gin.yml
+++ b/.github/workflows/gin.yml
@@ -8,6 +8,9 @@ on:
     branches:
       - master
 
+permissions:
+  contents: read
+
 jobs:
   lint:
     runs-on: ubuntu-latest
@@ -21,15 +24,15 @@ jobs:
       - name: Setup golangci-lint
         uses: golangci/golangci-lint-action@v3.2.0
         with:
-          version: v1.45.0
+          version: v1.48.0
           args: --verbose
   test:
     needs: lint
     strategy:
       matrix:
         os: [ubuntu-latest, macos-latest]
-        go: [1.15, 1.16, 1.17, 1.18]
-        test-tags: ['', nomsgpack]
+        go: [1.16, 1.17, 1.18, 1.19]
+        test-tags: ['', '-tags nomsgpack', '-tags "sonic avx"', '-tags go_json']
         include:
           - os: ubuntu-latest
             go-build: ~/.cache/go-build
@@ -68,6 +71,10 @@ jobs:
         uses: codecov/codecov-action@v3
         with:
           flags: ${{ matrix.os }},go-${{ matrix.go }},${{ matrix.test-tags }}
+
+      - name: Format
+        if: matrix.go-version == '1.19.x'
+        run: diff -u <(echo -n) <(gofmt -d .)
   notification-gitter:
     needs: test
     runs-on: ubuntu-latest
diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml
index 64ed8b2..654585b 100644
--- a/.github/workflows/goreleaser.yml
+++ b/.github/workflows/goreleaser.yml
@@ -19,7 +19,7 @@ jobs:
           fetch-depth: 0
       -
         name: Set up Go
-        uses: actions/setup-go@v2
+        uses: actions/setup-go@v3
         with:
           go-version: 1.17
       -
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1bc51a8..a682c8c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -113,7 +113,7 @@
 * chore(performance): improve countParams ([#2378](https://github.com/gin-gonic/gin/pull/2378))
 * Remove some functions that have the same effect as the bytes package ([#2387](https://github.com/gin-gonic/gin/pull/2387))
 * update:SetMode function ([#2321](https://github.com/gin-gonic/gin/pull/2321))
-* remove a unused type SecureJSONPrefix ([#2391](https://github.com/gin-gonic/gin/pull/2391))
+* remove an unused type SecureJSONPrefix ([#2391](https://github.com/gin-gonic/gin/pull/2391))
 * Add a redirect sample for POST method ([#2389](https://github.com/gin-gonic/gin/pull/2389))
 * Add CustomRecovery builtin middleware ([#2322](https://github.com/gin-gonic/gin/pull/2322))
 * binding: avoid 2038 problem on 32-bit architectures ([#2450](https://github.com/gin-gonic/gin/pull/2450))
diff --git a/Makefile b/Makefile
index 5d55b44..ebde4ee 100644
--- a/Makefile
+++ b/Makefile
@@ -11,7 +11,7 @@ TESTTAGS ?= ""
 test:
 	echo "mode: count" > coverage.out
 	for d in $(TESTFOLDER); do \
-		$(GO) test -tags $(TESTTAGS) -v -covermode=count -coverprofile=profile.out $$d > tmp.out; \
+		$(GO) test $(TESTTAGS) -v -covermode=count -coverprofile=profile.out $$d > tmp.out; \
 		cat tmp.out; \
 		if grep -q "^--- FAIL" tmp.out; then \
 			rm tmp.out; \
diff --git a/README.md b/README.md
index 2477d0b..760bde0 100644
--- a/README.md
+++ b/README.md
@@ -14,7 +14,6 @@
 
 Gin is a web framework written in Go (Golang). It features a martini-like API with performance that is up to 40 times faster thanks to [httprouter](https://github.com/julienschmidt/httprouter). If you need performance and good productivity, you will love Gin.
 
-
 ## Contents
 
 - [Gin Web Framework](#gin-web-framework)
@@ -23,7 +22,7 @@ Gin is a web framework written in Go (Golang). It features a martini-like API wi
   - [Quick start](#quick-start)
   - [Benchmarks](#benchmarks)
   - [Gin v1. stable](#gin-v1-stable)
-  - [Build with jsoniter/go-json](#build-with-json-replacement)
+  - [Build with json replacement](#build-with-json-replacement)
   - [Build without `MsgPack` rendering feature](#build-without-msgpack-rendering-feature)
   - [API Examples](#api-examples)
     - [Using GET, POST, PUT, PATCH, DELETE and OPTIONS](#using-get-post-put-patch-delete-and-options)
@@ -38,6 +37,7 @@ Gin is a web framework written in Go (Golang). It features a martini-like API wi
     - [Grouping routes](#grouping-routes)
     - [Blank Gin without middleware by default](#blank-gin-without-middleware-by-default)
     - [Using middleware](#using-middleware)
+    - [Custom Recovery behavior](#custom-recovery-behavior)
     - [How to write log file](#how-to-write-log-file)
     - [Custom Log Format](#custom-log-format)
     - [Controlling Log output coloring](#controlling-log-output-coloring)
@@ -75,6 +75,7 @@ Gin is a web framework written in Go (Golang). It features a martini-like API wi
     - [Build a single binary with templates](#build-a-single-binary-with-templates)
     - [Bind form-data request with custom struct](#bind-form-data-request-with-custom-struct)
     - [Try to bind body into different structs](#try-to-bind-body-into-different-structs)
+    - [Bind form-data request with custom struct and custom tag](#bind-form-data-request-with-custom-struct-and-custom-tag)
     - [http2 server push](#http2-server-push)
     - [Define format for the log of routes](#define-format-for-the-log-of-routes)
     - [Set and get a cookie](#set-and-get-a-cookie)
@@ -86,10 +87,10 @@ Gin is a web framework written in Go (Golang). It features a martini-like API wi
 
 To install Gin package, you need to install Go and set your Go workspace first.
 
-1. You first need [Go](https://golang.org/) installed (**version 1.15+ is required**), then you can use the below Go command to install Gin.
+1. You first need [Go](https://golang.org/) installed (**version 1.16+ is required**), then you can use the below Go command to install Gin.
 
 ```sh
-$ go get -u github.com/gin-gonic/gin
+go get -u github.com/gin-gonic/gin
 ```
 
 2. Import it in your code:
@@ -115,19 +116,19 @@ $ cat example.go
 package main
 
 import (
-	"net/http"
+  "net/http"
 
-	"github.com/gin-gonic/gin"
+  "github.com/gin-gonic/gin"
 )
 
 func main() {
-	r := gin.Default()
-	r.GET("/ping", func(c *gin.Context) {
-		c.JSON(http.StatusOK, gin.H{
-			"message": "pong",
-		})
-	})
-	r.Run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
+  r := gin.Default()
+  r.GET("/ping", func(c *gin.Context) {
+    c.JSON(http.StatusOK, gin.H{
+      "message": "pong",
+    })
+  })
+  r.Run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
 }
 ```
 
@@ -193,12 +194,21 @@ Gin uses a custom version of [HttpRouter](https://github.com/julienschmidt/httpr
 Gin uses `encoding/json` as default json package but you can change it by build from other tags.
 
 [jsoniter](https://github.com/json-iterator/go)
+
 ```sh
-$ go build -tags=jsoniter .
+go build -tags=jsoniter .
 ```
+
 [go-json](https://github.com/goccy/go-json)
+
+```sh
+go build -tags=go_json .
+```
+
+[sonic](https://github.com/bytedance/sonic) (you have to ensure that your cpu support avx instruction.)
+
 ```sh
-$ go build -tags=go_json .
+$ go build -tags="sonic avx" .
 ```
 
 ## Build without `MsgPack` rendering feature
@@ -206,7 +216,7 @@ $ go build -tags=go_json .
 Gin enables `MsgPack` rendering feature by default. But you can disable this feature by specifying `nomsgpack` build tag.
 
 ```sh
-$ go build -tags=nomsgpack .
+go build -tags=nomsgpack .
 ```
 
 This is useful to reduce the binary size of executable files. See the [detail information](https://github.com/gin-gonic/gin/pull/1852).
@@ -219,22 +229,22 @@ You can find a number of ready-to-run examples at [Gin examples repository](http
 
 ```go
 func main() {
-	// Creates a gin router with default middleware:
-	// logger and recovery (crash-free) middleware
-	router := gin.Default()
+  // Creates a gin router with default middleware:
+  // logger and recovery (crash-free) middleware
+  router := gin.Default()
 
-	router.GET("/someGet", getting)
-	router.POST("/somePost", posting)
-	router.PUT("/somePut", putting)
-	router.DELETE("/someDelete", deleting)
-	router.PATCH("/somePatch", patching)
-	router.HEAD("/someHead", head)
-	router.OPTIONS("/someOptions", options)
+  router.GET("/someGet", getting)
+  router.POST("/somePost", posting)
+  router.PUT("/somePut", putting)
+  router.DELETE("/someDelete", deleting)
+  router.PATCH("/somePatch", patching)
+  router.HEAD("/someHead", head)
+  router.OPTIONS("/someOptions", options)
 
-	// By default it serves on :8080 unless a
-	// PORT environment variable was defined.
-	router.Run()
-	// router.Run(":3000") for a hard coded port
+  // By default it serves on :8080 unless a
+  // PORT environment variable was defined.
+  router.Run()
+  // router.Run(":3000") for a hard coded port
 }
 ```
 
@@ -242,37 +252,37 @@ func main() {
 
 ```go
 func main() {
-	router := gin.Default()
+  router := gin.Default()
 
-	// This handler will match /user/john but will not match /user/ or /user
-	router.GET("/user/:name", func(c *gin.Context) {
-		name := c.Param("name")
-		c.String(http.StatusOK, "Hello %s", name)
-	})
+  // This handler will match /user/john but will not match /user/ or /user
+  router.GET("/user/:name", func(c *gin.Context) {
+    name := c.Param("name")
+    c.String(http.StatusOK, "Hello %s", name)
+  })
 
-	// However, this one will match /user/john/ and also /user/john/send
-	// If no other routers match /user/john, it will redirect to /user/john/
-	router.GET("/user/:name/*action", func(c *gin.Context) {
-		name := c.Param("name")
-		action := c.Param("action")
-		message := name + " is " + action
-		c.String(http.StatusOK, message)
-	})
+  // However, this one will match /user/john/ and also /user/john/send
+  // If no other routers match /user/john, it will redirect to /user/john/
+  router.GET("/user/:name/*action", func(c *gin.Context) {
+    name := c.Param("name")
+    action := c.Param("action")
+    message := name + " is " + action
+    c.String(http.StatusOK, message)
+  })
 
-	// For each matched request Context will hold the route definition
-	router.POST("/user/:name/*action", func(c *gin.Context) {
-		b := c.FullPath() == "/user/:name/*action" // true
-		c.String(http.StatusOK, "%t", b)
-	})
+  // For each matched request Context will hold the route definition
+  router.POST("/user/:name/*action", func(c *gin.Context) {
+    b := c.FullPath() == "/user/:name/*action" // true
+    c.String(http.StatusOK, "%t", b)
+  })
 
-	// This handler will add a new router for /user/groups.
-	// Exact routes are resolved before param routes, regardless of the order they were defined.
-	// Routes starting with /user/groups are never interpreted as /user/:name/... routes
-	router.GET("/user/groups", func(c *gin.Context) {
-		c.String(http.StatusOK, "The available groups are [...]")
-	})
+  // This handler will add a new router for /user/groups.
+  // Exact routes are resolved before param routes, regardless of the order they were defined.
+  // Routes starting with /user/groups are never interpreted as /user/:name/... routes
+  router.GET("/user/groups", func(c *gin.Context) {
+    c.String(http.StatusOK, "The available groups are [...]")
+  })
 
-	router.Run(":8080")
+  router.Run(":8080")
 }
 ```
 
@@ -280,17 +290,17 @@ func main() {
 
 ```go
 func main() {
-	router := gin.Default()
+  router := gin.Default()
 
-	// Query string parameters are parsed using the existing underlying request object.
-	// The request responds to a url matching:  /welcome?firstname=Jane&lastname=Doe
-	router.GET("/welcome", func(c *gin.Context) {
-		firstname := c.DefaultQuery("firstname", "Guest")
-		lastname := c.Query("lastname") // shortcut for c.Request.URL.Query().Get("lastname")
+  // Query string parameters are parsed using the existing underlying request object.
+  // The request responds to an url matching:  /welcome?firstname=Jane&lastname=Doe
+  router.GET("/welcome", func(c *gin.Context) {
+    firstname := c.DefaultQuery("firstname", "Guest")
+    lastname := c.Query("lastname") // shortcut for c.Request.URL.Query().Get("lastname")
 
-		c.String(http.StatusOK, "Hello %s %s", firstname, lastname)
-	})
-	router.Run(":8080")
+    c.String(http.StatusOK, "Hello %s %s", firstname, lastname)
+  })
+  router.Run(":8080")
 }
 ```
 
@@ -298,25 +308,25 @@ func main() {
 
 ```go
 func main() {
-	router := gin.Default()
+  router := gin.Default()
 
-	router.POST("/form_post", func(c *gin.Context) {
-		message := c.PostForm("message")
-		nick := c.DefaultPostForm("nick", "anonymous")
+  router.POST("/form_post", func(c *gin.Context) {
+    message := c.PostForm("message")
+    nick := c.DefaultPostForm("nick", "anonymous")
 
-		c.JSON(http.StatusOK, gin.H{
-			"status":  "posted",
-			"message": message,
-			"nick":    nick,
-		})
-	})
-	router.Run(":8080")
+    c.JSON(http.StatusOK, gin.H{
+      "status":  "posted",
+      "message": message,
+      "nick":    nick,
+    })
+  })
+  router.Run(":8080")
 }
 ```
 
 ### Another example: query + post form
 
-```
+```sh
 POST /post?id=1234&page=1 HTTP/1.1
 Content-Type: application/x-www-form-urlencoded
 
@@ -325,28 +335,28 @@ name=manu&message=this_is_great
 
 ```go
 func main() {
-	router := gin.Default()
+  router := gin.Default()
 
-	router.POST("/post", func(c *gin.Context) {
+  router.POST("/post", func(c *gin.Context) {
 
-		id := c.Query("id")
-		page := c.DefaultQuery("page", "0")
-		name := c.PostForm("name")
-		message := c.PostForm("message")
+    id := c.Query("id")
+    page := c.DefaultQuery("page", "0")
+    name := c.PostForm("name")
+    message := c.PostForm("message")
 
-		fmt.Printf("id: %s; page: %s; name: %s; message: %s", id, page, name, message)
-	})
-	router.Run(":8080")
+    fmt.Printf("id: %s; page: %s; name: %s; message: %s", id, page, name, message)
+  })
+  router.Run(":8080")
 }
 ```
 
-```
+```sh
 id: 1234; page: 1; name: manu; message: this_is_great
 ```
 
 ### Map as querystring or postform parameters
 
-```
+```sh
 POST /post?ids[a]=1234&ids[b]=hello HTTP/1.1
 Content-Type: application/x-www-form-urlencoded
 
@@ -355,20 +365,20 @@ names[first]=thinkerou&names[second]=tianou
 
 ```go
 func main() {
-	router := gin.Default()
+  router := gin.Default()
 
-	router.POST("/post", func(c *gin.Context) {
+  router.POST("/post", func(c *gin.Context) {
 
-		ids := c.QueryMap("ids")
-		names := c.PostFormMap("names")
+    ids := c.QueryMap("ids")
+    names := c.PostFormMap("names")
 
-		fmt.Printf("ids: %v; names: %v", ids, names)
-	})
-	router.Run(":8080")
+    fmt.Printf("ids: %v; names: %v", ids, names)
+  })
+  router.Run(":8080")
 }
 ```
 
-```
+```sh
 ids: map[b:hello a:1234]; names: map[second:tianou first:thinkerou]
 ```
 
@@ -384,20 +394,20 @@ References issue [#774](https://github.com/gin-gonic/gin/issues/774) and detail
 
 ```go
 func main() {
-	router := gin.Default()
-	// Set a lower memory limit for multipart forms (default is 32 MiB)
-	router.MaxMultipartMemory = 8 << 20  // 8 MiB
-	router.POST("/upload", func(c *gin.Context) {
-		// Single file
-		file, _ := c.FormFile("file")
-		log.Println(file.Filename)
+  router := gin.Default()
+  // Set a lower memory limit for multipart forms (default is 32 MiB)
+  router.MaxMultipartMemory = 8 << 20  // 8 MiB
+  router.POST("/upload", func(c *gin.Context) {
+    // Single file
+    file, _ := c.FormFile("file")
+    log.Println(file.Filename)
 
-		// Upload the file to specific dst.
-		c.SaveUploadedFile(file, dst)
+    // Upload the file to specific dst.
+    c.SaveUploadedFile(file, dst)
 
-		c.String(http.StatusOK, fmt.Sprintf("'%s' uploaded!", file.Filename))
-	})
-	router.Run(":8080")
+    c.String(http.StatusOK, fmt.Sprintf("'%s' uploaded!", file.Filename))
+  })
+  router.Run(":8080")
 }
 ```
 
@@ -415,23 +425,23 @@ See the detail [example code](https://github.com/gin-gonic/examples/tree/master/
 
 ```go
 func main() {
-	router := gin.Default()
-	// Set a lower memory limit for multipart forms (default is 32 MiB)
-	router.MaxMultipartMemory = 8 << 20  // 8 MiB
-	router.POST("/upload", func(c *gin.Context) {
-		// Multipart form
-		form, _ := c.MultipartForm()
-		files := form.File["upload[]"]
-
-		for _, file := range files {
-			log.Println(file.Filename)
-
-			// Upload the file to specific dst.
-			c.SaveUploadedFile(file, dst)
-		}
-		c.String(http.StatusOK, fmt.Sprintf("%d files uploaded!", len(files)))
-	})
-	router.Run(":8080")
+  router := gin.Default()
+  // Set a lower memory limit for multipart forms (default is 32 MiB)
+  router.MaxMultipartMemory = 8 << 20  // 8 MiB
+  router.POST("/upload", func(c *gin.Context) {
+    // Multipart form
+    form, _ := c.MultipartForm()
+    files := form.File["upload[]"]
+
+    for _, file := range files {
+      log.Println(file.Filename)
+
+      // Upload the file to specific dst.
+      c.SaveUploadedFile(file, dst)
+    }
+    c.String(http.StatusOK, fmt.Sprintf("%d files uploaded!", len(files)))
+  })
+  router.Run(":8080")
 }
 ```
 
@@ -448,25 +458,25 @@ curl -X POST http://localhost:8080/upload \
 
 ```go
 func main() {
-	router := gin.Default()
-
-	// Simple group: v1
-	v1 := router.Group("/v1")
-	{
-		v1.POST("/login", loginEndpoint)
-		v1.POST("/submit", submitEndpoint)
-		v1.POST("/read", readEndpoint)
-	}
+  router := gin.Default()
+
+  // Simple group: v1
+  v1 := router.Group("/v1")
+  {
+    v1.POST("/login", loginEndpoint)
+    v1.POST("/submit", submitEndpoint)
+    v1.POST("/read", readEndpoint)
+  }
 
-	// Simple group: v2
-	v2 := router.Group("/v2")
-	{
-		v2.POST("/login", loginEndpoint)
-		v2.POST("/submit", submitEndpoint)
-		v2.POST("/read", readEndpoint)
-	}
+  // Simple group: v2
+  v2 := router.Group("/v2")
+  {
+    v2.POST("/login", loginEndpoint)
+    v2.POST("/submit", submitEndpoint)
+    v2.POST("/read", readEndpoint)
+  }
 
-	router.Run(":8080")
+  router.Run(":8080")
 }
 ```
 
@@ -485,81 +495,83 @@ instead of
 r := gin.Default()
 ```
 
-
 ### Using middleware
+
 ```go
 func main() {
-	// Creates a router without any middleware by default
-	r := gin.New()
-
-	// Global middleware
-	// Logger middleware will write the logs to gin.DefaultWriter even if you set with GIN_MODE=release.
-	// By default gin.DefaultWriter = os.Stdout
-	r.Use(gin.Logger())
-
-	// Recovery middleware recovers from any panics and writes a 500 if there was one.
-	r.Use(gin.Recovery())
-
-	// Per route middleware, you can add as many as you desire.
-	r.GET("/benchmark", MyBenchLogger(), benchEndpoint)
-
-	// Authorization group
-	// authorized := r.Group("/", AuthRequired())
-	// exactly the same as:
-	authorized := r.Group("/")
-	// per group middleware! in this case we use the custom created
-	// AuthRequired() middleware just in the "authorized" group.
-	authorized.Use(AuthRequired())
-	{
-		authorized.POST("/login", loginEndpoint)
-		authorized.POST("/submit", submitEndpoint)
-		authorized.POST("/read", readEndpoint)
-
-		// nested group
-		testing := authorized.Group("testing")
-		// visit 0.0.0.0:8080/testing/analytics
-		testing.GET("/analytics", analyticsEndpoint)
-	}
+  // Creates a router without any middleware by default
+  r := gin.New()
+
+  // Global middleware
+  // Logger middleware will write the logs to gin.DefaultWriter even if you set with GIN_MODE=release.
+  // By default gin.DefaultWriter = os.Stdout
+  r.Use(gin.Logger())
+
+  // Recovery middleware recovers from any panics and writes a 500 if there was one.
+  r.Use(gin.Recovery())
+
+  // Per route middleware, you can add as many as you desire.
+  r.GET("/benchmark", MyBenchLogger(), benchEndpoint)
+
+  // Authorization group
+  // authorized := r.Group("/", AuthRequired())
+  // exactly the same as:
+  authorized := r.Group("/")
+  // per group middleware! in this case we use the custom created
+  // AuthRequired() middleware just in the "authorized" group.
+  authorized.Use(AuthRequired())
+  {
+    authorized.POST("/login", loginEndpoint)
+    authorized.POST("/submit", submitEndpoint)
+    authorized.POST("/read", readEndpoint)
+
+    // nested group
+    testing := authorized.Group("testing")
+    // visit 0.0.0.0:8080/testing/analytics
+    testing.GET("/analytics", analyticsEndpoint)
+  }
 
-	// Listen and serve on 0.0.0.0:8080
-	r.Run(":8080")
+  // Listen and serve on 0.0.0.0:8080
+  r.Run(":8080")
 }
 ```
 
 ### Custom Recovery behavior
+
 ```go
 func main() {
-	// Creates a router without any middleware by default
-	r := gin.New()
-
-	// Global middleware
-	// Logger middleware will write the logs to gin.DefaultWriter even if you set with GIN_MODE=release.
-	// By default gin.DefaultWriter = os.Stdout
-	r.Use(gin.Logger())
-
-	// Recovery middleware recovers from any panics and writes a 500 if there was one.
-	r.Use(gin.CustomRecovery(func(c *gin.Context, recovered interface{}) {
-		if err, ok := recovered.(string); ok {
-			c.String(http.StatusInternalServerError, fmt.Sprintf("error: %s", err))
-		}
-		c.AbortWithStatus(http.StatusInternalServerError)
-	}))
+  // Creates a router without any middleware by default
+  r := gin.New()
+
+  // Global middleware
+  // Logger middleware will write the logs to gin.DefaultWriter even if you set with GIN_MODE=release.
+  // By default gin.DefaultWriter = os.Stdout
+  r.Use(gin.Logger())
+
+  // Recovery middleware recovers from any panics and writes a 500 if there was one.
+  r.Use(gin.CustomRecovery(func(c *gin.Context, recovered interface{}) {
+    if err, ok := recovered.(string); ok {
+      c.String(http.StatusInternalServerError, fmt.Sprintf("error: %s", err))
+    }
+    c.AbortWithStatus(http.StatusInternalServerError)
+  }))
 
-	r.GET("/panic", func(c *gin.Context) {
-		// panic with a string -- the custom middleware could save this to a database or report it to the user
-		panic("foo")
-	})
+  r.GET("/panic", func(c *gin.Context) {
+    // panic with a string -- the custom middleware could save this to a database or report it to the user
+    panic("foo")
+  })
 
-	r.GET("/", func(c *gin.Context) {
-		c.String(http.StatusOK, "ohai")
-	})
+  r.GET("/", func(c *gin.Context) {
+    c.String(http.StatusOK, "ohai")
+  })
 
-	// Listen and serve on 0.0.0.0:8080
-	r.Run(":8080")
+  // Listen and serve on 0.0.0.0:8080
+  r.Run(":8080")
 }
 ```
 
 ### How to write log file
+
 ```go
 func main() {
     // Disable Console Color, you don't need console color when writing the logs to file.
@@ -582,39 +594,41 @@ func main() {
 ```
 
 ### Custom Log Format
+
 ```go
 func main() {
-	router := gin.New()
+  router := gin.New()
 
-	// LoggerWithFormatter middleware will write the logs to gin.DefaultWriter
-	// By default gin.DefaultWriter = os.Stdout
-	router.Use(gin.LoggerWithFormatter(func(param gin.LogFormatterParams) string {
+  // LoggerWithFormatter middleware will write the logs to gin.DefaultWriter
+  // By default gin.DefaultWriter = os.Stdout
+  router.Use(gin.LoggerWithFormatter(func(param gin.LogFormatterParams) string {
 
-		// your custom format
-		return fmt.Sprintf("%s - [%s] \"%s %s %s %d %s \"%s\" %s\"\n",
-				param.ClientIP,
-				param.TimeStamp.Format(time.RFC1123),
-				param.Method,
-				param.Path,
-				param.Request.Proto,
-				param.StatusCode,
-				param.Latency,
-				param.Request.UserAgent(),
-				param.ErrorMessage,
-		)
-	}))
-	router.Use(gin.Recovery())
+    // your custom format
+    return fmt.Sprintf("%s - [%s] \"%s %s %s %d %s \"%s\" %s\"\n",
+        param.ClientIP,
+        param.TimeStamp.Format(time.RFC1123),
+        param.Method,
+        param.Path,
+        param.Request.Proto,
+        param.StatusCode,
+        param.Latency,
+        param.Request.UserAgent(),
+        param.ErrorMessage,
+    )
+  }))
+  router.Use(gin.Recovery())
 
-	router.GET("/ping", func(c *gin.Context) {
-		c.String(http.StatusOK, "pong")
-	})
+  router.GET("/ping", func(c *gin.Context) {
+    c.String(http.StatusOK, "pong")
+  })
 
-	router.Run(":8080")
+  router.Run(":8080")
 }
 ```
 
-**Sample Output**
-```
+Sample Output
+
+```sh
 ::1 - [Fri, 07 Dec 2018 17:04:38 JST] "GET /ping HTTP/1.1 200 122.767µs "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.80 Safari/537.36" "
 ```
 
@@ -669,6 +683,7 @@ Gin uses [**go-playground/validator/v10**](https://github.com/go-playground/vali
 Note that you need to set the corresponding binding tag on all fields you want to bind. For example, when binding from JSON, set `json:"fieldname"`.
 
 Also, Gin provides two sets of methods for binding:
+
 - **Type** - Must bind
   - **Methods** - `Bind`, `BindJSON`, `BindXML`, `BindQuery`, `BindYAML`, `BindHeader`, `BindTOML`
   - **Behavior** - These methods use `MustBindWith` under the hood. If there is a binding error, the request is aborted with `c.AbortWithError(400, err).SetType(ErrorTypeBind)`. This sets the response status code to 400 and the `Content-Type` header is set to `text/plain; charset=utf-8`. Note that if you try to set the response code after this, it will result in a warning `[GIN-debug] [WARNING] Headers were already written. Wanted to override status code 400 with 422`. If you wish to have greater control over the behavior, consider using the `ShouldBind` equivalent method.
@@ -678,79 +693,80 @@ Also, Gin provides two sets of methods for binding:
 
 When using the Bind-method, Gin tries to infer the binder depending on the Content-Type header. If you are sure what you are binding, you can use `MustBindWith` or `ShouldBindWith`.
 
-You can also specify that specific fields are required. If a field is decorated with `binding:"required"` and has a empty value when binding, an error will be returned.
+You can also specify that specific fields are required. If a field is decorated with `binding:"required"` and has an empty value when binding, an error will be returned.
 
 ```go
 // Binding from JSON
 type Login struct {
-	User     string `form:"user" json:"user" xml:"user"  binding:"required"`
-	Password string `form:"password" json:"password" xml:"password" binding:"required"`
+  User     string `form:"user" json:"user" xml:"user"  binding:"required"`
+  Password string `form:"password" json:"password" xml:"password" binding:"required"`
 }
 
 func main() {
-	router := gin.Default()
-
-	// Example for binding JSON ({"user": "manu", "password": "123"})
-	router.POST("/loginJSON", func(c *gin.Context) {
-		var json Login
-		if err := c.ShouldBindJSON(&json); err != nil {
-			c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
-			return
-		}
-
-		if json.User != "manu" || json.Password != "123" {
-			c.JSON(http.StatusUnauthorized, gin.H{"status": "unauthorized"})
-			return
-		}
-
-		c.JSON(http.StatusOK, gin.H{"status": "you are logged in"})
-	})
-
-	// Example for binding XML (
-	//	<?xml version="1.0" encoding="UTF-8"?>
-	//	<root>
-	//		<user>manu</user>
-	//		<password>123</password>
-	//	</root>)
-	router.POST("/loginXML", func(c *gin.Context) {
-		var xml Login
-		if err := c.ShouldBindXML(&xml); err != nil {
-			c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
-			return
-		}
-
-		if xml.User != "manu" || xml.Password != "123" {
-			c.JSON(http.StatusUnauthorized, gin.H{"status": "unauthorized"})
-			return
-		}
-
-		c.JSON(http.StatusOK, gin.H{"status": "you are logged in"})
-	})
-
-	// Example for binding a HTML form (user=manu&password=123)
-	router.POST("/loginForm", func(c *gin.Context) {
-		var form Login
-		// This will infer what binder to use depending on the content-type header.
-		if err := c.ShouldBind(&form); err != nil {
-			c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
-			return
-		}
-
-		if form.User != "manu" || form.Password != "123" {
-			c.JSON(http.StatusUnauthorized, gin.H{"status": "unauthorized"})
-			return
-		}
-
-		c.JSON(http.StatusOK, gin.H{"status": "you are logged in"})
-	})
-
-	// Listen and serve on 0.0.0.0:8080
-	router.Run(":8080")
-}
-```
-
-**Sample request**
-```shell
+  router := gin.Default()
+
+  // Example for binding JSON ({"user": "manu", "password": "123"})
+  router.POST("/loginJSON", func(c *gin.Context) {
+    var json Login
+    if err := c.ShouldBindJSON(&json); err != nil {
+      c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
+      return
+    }
+
+    if json.User != "manu" || json.Password != "123" {
+      c.JSON(http.StatusUnauthorized, gin.H{"status": "unauthorized"})
+      return
+    }
+
+    c.JSON(http.StatusOK, gin.H{"status": "you are logged in"})
+  })
+
+  // Example for binding XML (
+  //  <?xml version="1.0" encoding="UTF-8"?>
+  //  <root>
+  //    <user>manu</user>
+  //    <password>123</password>
+  //  </root>)
+  router.POST("/loginXML", func(c *gin.Context) {
+    var xml Login
+    if err := c.ShouldBindXML(&xml); err != nil {
+      c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
+      return
+    }
+
+    if xml.User != "manu" || xml.Password != "123" {
+      c.JSON(http.StatusUnauthorized, gin.H{"status": "unauthorized"})
+      return
+    }
+
+    c.JSON(http.StatusOK, gin.H{"status": "you are logged in"})
+  })
+
+  // Example for binding a HTML form (user=manu&password=123)
+  router.POST("/loginForm", func(c *gin.Context) {
+    var form Login
+    // This will infer what binder to use depending on the content-type header.
+    if err := c.ShouldBind(&form); err != nil {
+      c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
+      return
+    }
+
+    if form.User != "manu" || form.Password != "123" {
+      c.JSON(http.StatusUnauthorized, gin.H{"status": "unauthorized"})
+      return
+    }
+
+    c.JSON(http.StatusOK, gin.H{"status": "you are logged in"})
+  })
+
+  // Listen and serve on 0.0.0.0:8080
+  router.Run(":8080")
+}
+```
+
+Sample request
+
+```sh
 $ curl -v -X POST \
   http://localhost:8080/loginJSON \
   -H 'content-type: application/json' \
@@ -771,9 +787,7 @@ $ curl -v -X POST \
 {"error":"Key: 'Login.Password' Error:Field validation for 'Password' failed on the 'required' tag"}
 ```
 
-**Skip validate**
-
-When running the above example using the above the `curl` command, it returns error. Because the example use `binding:"required"` for `Password`. If use `binding:"-"` for `Password`, then it will not return error when running the above example again.
+Skip validate: when running the above example using the above the `curl` command, it returns error. Because the example use `binding:"required"` for `Password`. If use `binding:"-"` for `Password`, then it will not return error when running the above example again.
 
 ### Custom Validators
 
@@ -783,49 +797,49 @@ It is also possible to register custom validators. See the [example code](https:
 package main
 
 import (
-	"net/http"
-	"time"
+  "net/http"
+  "time"
 
-	"github.com/gin-gonic/gin"
-	"github.com/gin-gonic/gin/binding"
-	"github.com/go-playground/validator/v10"
+  "github.com/gin-gonic/gin"
+  "github.com/gin-gonic/gin/binding"
+  "github.com/go-playground/validator/v10"
 )
 
 // Booking contains binded and validated data.
 type Booking struct {
-	CheckIn  time.Time `form:"check_in" binding:"required,bookabledate" time_format:"2006-01-02"`
-	CheckOut time.Time `form:"check_out" binding:"required,gtfield=CheckIn" time_format:"2006-01-02"`
+  CheckIn  time.Time `form:"check_in" binding:"required,bookabledate" time_format:"2006-01-02"`
+  CheckOut time.Time `form:"check_out" binding:"required,gtfield=CheckIn" time_format:"2006-01-02"`
 }
 
 var bookableDate validator.Func = func(fl validator.FieldLevel) bool {
-	date, ok := fl.Field().Interface().(time.Time)
-	if ok {
-		today := time.Now()
-		if today.After(date) {
-			return false
-		}
-	}
-	return true
+  date, ok := fl.Field().Interface().(time.Time)
+  if ok {
+    today := time.Now()
+    if today.After(date) {
+      return false
+    }
+  }
+  return true
 }
 
 func main() {
-	route := gin.Default()
+  route := gin.Default()
 
-	if v, ok := binding.Validator.Engine().(*validator.Validate); ok {
-		v.RegisterValidation("bookabledate", bookableDate)
-	}
+  if v, ok := binding.Validator.Engine().(*validator.Validate); ok {
+    v.RegisterValidation("bookabledate", bookableDate)
+  }
 
-	route.GET("/bookable", getBookable)
-	route.Run(":8085")
+  route.GET("/bookable", getBookable)
+  route.Run(":8085")
 }
 
 func getBookable(c *gin.Context) {
-	var b Booking
-	if err := c.ShouldBindWith(&b, binding.Query); err == nil {
-		c.JSON(http.StatusOK, gin.H{"message": "Booking dates are valid!"})
-	} else {
-		c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
-	}
+  var b Booking
+  if err := c.ShouldBindWith(&b, binding.Query); err == nil {
+    c.JSON(http.StatusOK, gin.H{"message": "Booking dates are valid!"})
+  } else {
+    c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
+  }
 }
 ```
 
@@ -851,31 +865,31 @@ See the [struct-lvl-validation example](https://github.com/gin-gonic/examples/tr
 package main
 
 import (
-	"log"
-	"net/http"
+  "log"
+  "net/http"
 
-	"github.com/gin-gonic/gin"
+  "github.com/gin-gonic/gin"
 )
 
 type Person struct {
-	Name    string `form:"name"`
-	Address string `form:"address"`
+  Name    string `form:"name"`
+  Address string `form:"address"`
 }
 
 func main() {
-	route := gin.Default()
-	route.Any("/testing", startPage)
-	route.Run(":8085")
+  route := gin.Default()
+  route.Any("/testing", startPage)
+  route.Run(":8085")
 }
 
 func startPage(c *gin.Context) {
-	var person Person
-	if c.ShouldBindQuery(&person) == nil {
-		log.Println("====== Only Bind By Query String ======")
-		log.Println(person.Name)
-		log.Println(person.Address)
-	}
-	c.String(http.StatusOK, "Success")
+  var person Person
+  if c.ShouldBindQuery(&person) == nil {
+    log.Println("====== Only Bind By Query String ======")
+    log.Println(person.Name)
+    log.Println(person.Address)
+  }
+  c.String(http.StatusOK, "Success")
 }
 
 ```
@@ -888,11 +902,11 @@ See the [detail information](https://github.com/gin-gonic/gin/issues/742#issueco
 package main
 
 import (
-	"log"
-	"net/http"
-	"time"
+  "log"
+  "net/http"
+  "time"
 
-	"github.com/gin-gonic/gin"
+  "github.com/gin-gonic/gin"
 )
 
 type Person struct {
@@ -904,16 +918,16 @@ type Person struct {
 }
 
 func main() {
-	route := gin.Default()
-	route.GET("/testing", startPage)
-	route.Run(":8085")
+  route := gin.Default()
+  route.GET("/testing", startPage)
+  route.Run(":8085")
 }
 
 func startPage(c *gin.Context) {
-	var person Person
-	// If `GET`, only `Form` binding engine (`query`) used.
-	// If `POST`, first checks the `content-type` for `JSON` or `XML`, then uses `Form` (`form-data`).
-	// See more at https://github.com/gin-gonic/gin/blob/master/binding/binding.go#L88
+  var person Person
+  // If `GET`, only `Form` binding engine (`query`) used.
+  // If `POST`, first checks the `content-type` for `JSON` or `XML`, then uses `Form` (`form-data`).
+  // See more at https://github.com/gin-gonic/gin/blob/master/binding/binding.go#L88
         if c.ShouldBind(&person) == nil {
                 log.Println(person.Name)
                 log.Println(person.Address)
@@ -922,13 +936,14 @@ func startPage(c *gin.Context) {
                 log.Println(person.UnixTime)
         }
 
-	c.String(http.StatusOK, "Success")
+  c.String(http.StatusOK, "Success")
 }
 ```
 
 Test it with:
+
 ```sh
-$ curl -X GET "localhost:8085/testing?name=appleboy&address=xyz&birthday=1992-03-15&createTime=1562400033000000123&unixTime=1562400033"
+curl -X GET "localhost:8085/testing?name=appleboy&address=xyz&birthday=1992-03-15&createTime=1562400033000000123&unixTime=1562400033"
 ```
 
 ### Bind Uri
@@ -939,34 +954,35 @@ See the [detail information](https://github.com/gin-gonic/gin/issues/846).
 package main
 
 import (
-	"net/http"
+  "net/http"
 
-	"github.com/gin-gonic/gin"
+  "github.com/gin-gonic/gin"
 )
 
 type Person struct {
-	ID string `uri:"id" binding:"required,uuid"`
-	Name string `uri:"name" binding:"required"`
+  ID string `uri:"id" binding:"required,uuid"`
+  Name string `uri:"name" binding:"required"`
 }
 
 func main() {
-	route := gin.Default()
-	route.GET("/:name/:id", func(c *gin.Context) {
-		var person Person
-		if err := c.ShouldBindUri(&person); err != nil {
-			c.JSON(http.StatusBadRequest, gin.H{"msg": err.Error()})
-			return
-		}
-		c.JSON(http.StatusOK, gin.H{"name": person.Name, "uuid": person.ID})
-	})
-	route.Run(":8088")
+  route := gin.Default()
+  route.GET("/:name/:id", func(c *gin.Context) {
+    var person Person
+    if err := c.ShouldBindUri(&person); err != nil {
+      c.JSON(http.StatusBadRequest, gin.H{"msg": err.Error()})
+      return
+    }
+    c.JSON(http.StatusOK, gin.H{"name": person.Name, "uuid": person.ID})
+  })
+  route.Run(":8088")
 }
 ```
 
 Test it with:
+
 ```sh
-$ curl -v localhost:8088/thinkerou/987fbc97-4bed-5078-9f07-9141ba07c9f3
-$ curl -v localhost:8088/thinkerou/not-uuid
+curl -v localhost:8088/thinkerou/987fbc97-4bed-5078-9f07-9141ba07c9f3
+curl -v localhost:8088/thinkerou/not-uuid
 ```
 
 ### Bind Header
@@ -975,31 +991,31 @@ $ curl -v localhost:8088/thinkerou/not-uuid
 package main
 
 import (
-	"fmt"
-	"net/http"
+  "fmt"
+  "net/http"
 
-	"github.com/gin-gonic/gin"
+  "github.com/gin-gonic/gin"
 )
 
 type testHeader struct {
-	Rate   int    `header:"Rate"`
-	Domain string `header:"Domain"`
+  Rate   int    `header:"Rate"`
+  Domain string `header:"Domain"`
 }
 
 func main() {
-	r := gin.Default()
-	r.GET("/", func(c *gin.Context) {
-		h := testHeader{}
+  r := gin.Default()
+  r.GET("/", func(c *gin.Context) {
+    h := testHeader{}
 
-		if err := c.ShouldBindHeader(&h); err != nil {
-			c.JSON(http.StatusOK, err)
-		}
+    if err := c.ShouldBindHeader(&h); err != nil {
+      c.JSON(http.StatusOK, err)
+    }
 
-		fmt.Printf("%#v\n", h)
-		c.JSON(http.StatusOK, gin.H{"Rate": h.Rate, "Domain": h.Domain})
-	})
+    fmt.Printf("%#v\n", h)
+    c.JSON(http.StatusOK, gin.H{"Rate": h.Rate, "Domain": h.Domain})
+  })
 
-	r.Run()
+  r.Run()
 
 // client
 // curl -H "rate:300" -H "domain:music" 127.0.0.1:8080/
@@ -1050,7 +1066,7 @@ form.html
 
 result:
 
-```
+```json
 {"color":["red","green","blue"]}
 ```
 
@@ -1058,94 +1074,95 @@ result:
 
 ```go
 type ProfileForm struct {
-	Name   string                `form:"name" binding:"required"`
-	Avatar *multipart.FileHeader `form:"avatar" binding:"required"`
+  Name   string                `form:"name" binding:"required"`
+  Avatar *multipart.FileHeader `form:"avatar" binding:"required"`
 
-	// or for multiple files
-	// Avatars []*multipart.FileHeader `form:"avatar" binding:"required"`
+  // or for multiple files
+  // Avatars []*multipart.FileHeader `form:"avatar" binding:"required"`
 }
 
 func main() {
-	router := gin.Default()
-	router.POST("/profile", func(c *gin.Context) {
-		// you can bind multipart form with explicit binding declaration:
-		// c.ShouldBindWith(&form, binding.Form)
-		// or you can simply use autobinding with ShouldBind method:
-		var form ProfileForm
-		// in this case proper binding will be automatically selected
-		if err := c.ShouldBind(&form); err != nil {
-			c.String(http.StatusBadRequest, "bad request")
-			return
-		}
+  router := gin.Default()
+  router.POST("/profile", func(c *gin.Context) {
+    // you can bind multipart form with explicit binding declaration:
+    // c.ShouldBindWith(&form, binding.Form)
+    // or you can simply use autobinding with ShouldBind method:
+    var form ProfileForm
+    // in this case proper binding will be automatically selected
+    if err := c.ShouldBind(&form); err != nil {
+      c.String(http.StatusBadRequest, "bad request")
+      return
+    }
 
-		err := c.SaveUploadedFile(form.Avatar, form.Avatar.Filename)
-		if err != nil {
-			c.String(http.StatusInternalServerError, "unknown error")
-			return
-		}
+    err := c.SaveUploadedFile(form.Avatar, form.Avatar.Filename)
+    if err != nil {
+      c.String(http.StatusInternalServerError, "unknown error")
+      return
+    }
 
-		// db.Save(&form)
+    // db.Save(&form)
 
-		c.String(http.StatusOK, "ok")
-	})
-	router.Run(":8080")
+    c.String(http.StatusOK, "ok")
+  })
+  router.Run(":8080")
 }
 ```
 
 Test it with:
+
 ```sh
-$ curl -X POST -v --form name=user --form "avatar=@./avatar.png" http://localhost:8080/profile
+curl -X POST -v --form name=user --form "avatar=@./avatar.png" http://localhost:8080/profile
 ```
 
 ### XML, JSON, YAML and ProtoBuf rendering
 
 ```go
 func main() {
-	r := gin.Default()
-
-	// gin.H is a shortcut for map[string]interface{}
-	r.GET("/someJSON", func(c *gin.Context) {
-		c.JSON(http.StatusOK, gin.H{"message": "hey", "status": http.StatusOK})
-	})
-
-	r.GET("/moreJSON", func(c *gin.Context) {
-		// You also can use a struct
-		var msg struct {
-			Name    string `json:"user"`
-			Message string
-			Number  int
-		}
-		msg.Name = "Lena"
-		msg.Message = "hey"
-		msg.Number = 123
-		// Note that msg.Name becomes "user" in the JSON
-		// Will output  :   {"user": "Lena", "Message": "hey", "Number": 123}
-		c.JSON(http.StatusOK, msg)
-	})
-
-	r.GET("/someXML", func(c *gin.Context) {
-		c.XML(http.StatusOK, gin.H{"message": "hey", "status": http.StatusOK})
-	})
-
-	r.GET("/someYAML", func(c *gin.Context) {
-		c.YAML(http.StatusOK, gin.H{"message": "hey", "status": http.StatusOK})
-	})
-
-	r.GET("/someProtoBuf", func(c *gin.Context) {
-		reps := []int64{int64(1), int64(2)}
-		label := "test"
-		// The specific definition of protobuf is written in the testdata/protoexample file.
-		data := &protoexample.Test{
-			Label: &label,
-			Reps:  reps,
-		}
-		// Note that data becomes binary data in the response
-		// Will output protoexample.Test protobuf serialized data
-		c.ProtoBuf(http.StatusOK, data)
-	})
-
-	// Listen and serve on 0.0.0.0:8080
-	r.Run(":8080")
+  r := gin.Default()
+
+  // gin.H is a shortcut for map[string]interface{}
+  r.GET("/someJSON", func(c *gin.Context) {
+    c.JSON(http.StatusOK, gin.H{"message": "hey", "status": http.StatusOK})
+  })
+
+  r.GET("/moreJSON", func(c *gin.Context) {
+    // You also can use a struct
+    var msg struct {
+      Name    string `json:"user"`
+      Message string
+      Number  int
+    }
+    msg.Name = "Lena"
+    msg.Message = "hey"
+    msg.Number = 123
+    // Note that msg.Name becomes "user" in the JSON
+    // Will output  :   {"user": "Lena", "Message": "hey", "Number": 123}
+    c.JSON(http.StatusOK, msg)
+  })
+
+  r.GET("/someXML", func(c *gin.Context) {
+    c.XML(http.StatusOK, gin.H{"message": "hey", "status": http.StatusOK})
+  })
+
+  r.GET("/someYAML", func(c *gin.Context) {
+    c.YAML(http.StatusOK, gin.H{"message": "hey", "status": http.StatusOK})
+  })
+
+  r.GET("/someProtoBuf", func(c *gin.Context) {
+    reps := []int64{int64(1), int64(2)}
+    label := "test"
+    // The specific definition of protobuf is written in the testdata/protoexample file.
+    data := &protoexample.Test{
+      Label: &label,
+      Reps:  reps,
+    }
+    // Note that data becomes binary data in the response
+    // Will output protoexample.Test protobuf serialized data
+    c.ProtoBuf(http.StatusOK, data)
+  })
+
+  // Listen and serve on 0.0.0.0:8080
+  r.Run(":8080")
 }
 ```
 
@@ -1155,42 +1172,43 @@ Using SecureJSON to prevent json hijacking. Default prepends `"while(1),"` to re
 
 ```go
 func main() {
-	r := gin.Default()
+  r := gin.Default()
 
-	// You can also use your own secure json prefix
-	// r.SecureJsonPrefix(")]}',\n")
+  // You can also use your own secure json prefix
+  // r.SecureJsonPrefix(")]}',\n")
 
-	r.GET("/someJSON", func(c *gin.Context) {
-		names := []string{"lena", "austin", "foo"}
+  r.GET("/someJSON", func(c *gin.Context) {
+    names := []string{"lena", "austin", "foo"}
 
-		// Will output  :   while(1);["lena","austin","foo"]
-		c.SecureJSON(http.StatusOK, names)
-	})
+    // Will output  :   while(1);["lena","austin","foo"]
+    c.SecureJSON(http.StatusOK, names)
+  })
 
-	// Listen and serve on 0.0.0.0:8080
-	r.Run(":8080")
+  // Listen and serve on 0.0.0.0:8080
+  r.Run(":8080")
 }
 ```
+
 #### JSONP
 
 Using JSONP to request data from a server  in a different domain. Add callback to response body if the query parameter callback exists.
 
 ```go
 func main() {
-	r := gin.Default()
+  r := gin.Default()
 
-	r.GET("/JSONP", func(c *gin.Context) {
-		data := gin.H{
-			"foo": "bar",
-		}
+  r.GET("/JSONP", func(c *gin.Context) {
+    data := gin.H{
+      "foo": "bar",
+    }
 
-		//callback is x
-		// Will output  :   x({\"foo\":\"bar\"})
-		c.JSONP(http.StatusOK, data)
-	})
+    //callback is x
+    // Will output  :   x({\"foo\":\"bar\"})
+    c.JSONP(http.StatusOK, data)
+  })
 
-	// Listen and serve on 0.0.0.0:8080
-	r.Run(":8080")
+  // Listen and serve on 0.0.0.0:8080
+  r.Run(":8080")
 
         // client
         // curl http://127.0.0.1:8080/JSONP?callback=x
@@ -1203,20 +1221,20 @@ Using AsciiJSON to Generates ASCII-only JSON with escaped non-ASCII characters.
 
 ```go
 func main() {
-	r := gin.Default()
+  r := gin.Default()
 
-	r.GET("/someJSON", func(c *gin.Context) {
-		data := gin.H{
-			"lang": "GO语言",
-			"tag":  "<br>",
-		}
+  r.GET("/someJSON", func(c *gin.Context) {
+    data := gin.H{
+      "lang": "GO语言",
+      "tag":  "<br>",
+    }
 
-		// will output : {"lang":"GO\u8bed\u8a00","tag":"\u003cbr\u003e"}
-		c.AsciiJSON(http.StatusOK, data)
-	})
+    // will output : {"lang":"GO\u8bed\u8a00","tag":"\u003cbr\u003e"}
+    c.AsciiJSON(http.StatusOK, data)
+  })
 
-	// Listen and serve on 0.0.0.0:8080
-	r.Run(":8080")
+  // Listen and serve on 0.0.0.0:8080
+  r.Run(":8080")
 }
 ```
 
@@ -1227,24 +1245,24 @@ This feature is unavailable in Go 1.6 and lower.
 
 ```go
 func main() {
-	r := gin.Default()
+  r := gin.Default()
 
-	// Serves unicode entities
-	r.GET("/json", func(c *gin.Context) {
-		c.JSON(http.StatusOK, gin.H{
-			"html": "<b>Hello, world!</b>",
-		})
-	})
+  // Serves unicode entities
+  r.GET("/json", func(c *gin.Context) {
+    c.JSON(http.StatusOK, gin.H{
+      "html": "<b>Hello, world!</b>",
+    })
+  })
 
-	// Serves literal characters
-	r.GET("/purejson", func(c *gin.Context) {
-		c.PureJSON(http.StatusOK, gin.H{
-			"html": "<b>Hello, world!</b>",
-		})
-	})
+  // Serves literal characters
+  r.GET("/purejson", func(c *gin.Context) {
+    c.PureJSON(http.StatusOK, gin.H{
+      "html": "<b>Hello, world!</b>",
+    })
+  })
 
-	// listen and serve on 0.0.0.0:8080
-	r.Run(":8080")
+  // listen and serve on 0.0.0.0:8080
+  r.Run(":8080")
 }
 ```
 
@@ -1252,14 +1270,14 @@ func main() {
 
 ```go
 func main() {
-	router := gin.Default()
-	router.Static("/assets", "./assets")
-	router.StaticFS("/more_static", http.Dir("my_file_system"))
-	router.StaticFile("/favicon.ico", "./resources/favicon.ico")
-	router.StaticFileFS("/more_favicon.ico", "more_favicon.ico", http.Dir("my_file_system"))
-	
-	// Listen and serve on 0.0.0.0:8080
-	router.Run(":8080")
+  router := gin.Default()
+  router.Static("/assets", "./assets")
+  router.StaticFS("/more_static", http.Dir("my_file_system"))
+  router.StaticFile("/favicon.ico", "./resources/favicon.ico")
+  router.StaticFileFS("/more_favicon.ico", "more_favicon.ico", http.Dir("my_file_system"))
+  
+  // Listen and serve on 0.0.0.0:8080
+  router.Run(":8080")
 }
 ```
 
@@ -1267,16 +1285,16 @@ func main() {
 
 ```go
 func main() {
-	router := gin.Default()
+  router := gin.Default()
 
-	router.GET("/local/file", func(c *gin.Context) {
-		c.File("local/file.go")
-	})
+  router.GET("/local/file", func(c *gin.Context) {
+    c.File("local/file.go")
+  })
 
-	var fs http.FileSystem = // ...
-	router.GET("/fs/file", func(c *gin.Context) {
-		c.FileFromFS("fs/file.go", fs)
-	})
+  var fs http.FileSystem = // ...
+  router.GET("/fs/file", func(c *gin.Context) {
+    c.FileFromFS("fs/file.go", fs)
+  })
 }
 
 ```
@@ -1285,26 +1303,26 @@ func main() {
 
 ```go
 func main() {
-	router := gin.Default()
-	router.GET("/someDataFromReader", func(c *gin.Context) {
-		response, err := http.Get("https://raw.githubusercontent.com/gin-gonic/logo/master/color.png")
-		if err != nil || response.StatusCode != http.StatusOK {
-			c.Status(http.StatusServiceUnavailable)
-			return
-		}
+  router := gin.Default()
+  router.GET("/someDataFromReader", func(c *gin.Context) {
+    response, err := http.Get("https://raw.githubusercontent.com/gin-gonic/logo/master/color.png")
+    if err != nil || response.StatusCode != http.StatusOK {
+      c.Status(http.StatusServiceUnavailable)
+      return
+    }
 
-		reader := response.Body
- 		defer reader.Close()
-		contentLength := response.ContentLength
-		contentType := response.Header.Get("Content-Type")
+    reader := response.Body
+     defer reader.Close()
+    contentLength := response.ContentLength
+    contentType := response.Header.Get("Content-Type")
 
-		extraHeaders := map[string]string{
-			"Content-Disposition": `attachment; filename="gopher.png"`,
-		}
+    extraHeaders := map[string]string{
+      "Content-Disposition": `attachment; filename="gopher.png"`,
+    }
 
-		c.DataFromReader(http.StatusOK, contentLength, contentType, reader, extraHeaders)
-	})
-	router.Run(":8080")
+    c.DataFromReader(http.StatusOK, contentLength, contentType, reader, extraHeaders)
+  })
+  router.Run(":8080")
 }
 ```
 
@@ -1314,15 +1332,15 @@ Using LoadHTMLGlob() or LoadHTMLFiles()
 
 ```go
 func main() {
-	router := gin.Default()
-	router.LoadHTMLGlob("templates/*")
-	//router.LoadHTMLFiles("templates/template1.html", "templates/template2.html")
-	router.GET("/index", func(c *gin.Context) {
-		c.HTML(http.StatusOK, "index.tmpl", gin.H{
-			"title": "Main website",
-		})
-	})
-	router.Run(":8080")
+  router := gin.Default()
+  router.LoadHTMLGlob("templates/*")
+  //router.LoadHTMLFiles("templates/template1.html", "templates/template2.html")
+  router.GET("/index", func(c *gin.Context) {
+    c.HTML(http.StatusOK, "index.tmpl", gin.H{
+      "title": "Main website",
+    })
+  })
+  router.Run(":8080")
 }
 ```
 
@@ -1330,9 +1348,9 @@ templates/index.tmpl
 
 ```html
 <html>
-	<h1>
-		{{ .title }}
-	</h1>
+  <h1>
+    {{ .title }}
+  </h1>
 </html>
 ```
 
@@ -1340,19 +1358,19 @@ Using templates with same name in different directories
 
 ```go
 func main() {
-	router := gin.Default()
-	router.LoadHTMLGlob("templates/**/*")
-	router.GET("/posts/index", func(c *gin.Context) {
-		c.HTML(http.StatusOK, "posts/index.tmpl", gin.H{
-			"title": "Posts",
-		})
-	})
-	router.GET("/users/index", func(c *gin.Context) {
-		c.HTML(http.StatusOK, "users/index.tmpl", gin.H{
-			"title": "Users",
-		})
-	})
-	router.Run(":8080")
+  router := gin.Default()
+  router.LoadHTMLGlob("templates/**/*")
+  router.GET("/posts/index", func(c *gin.Context) {
+    c.HTML(http.StatusOK, "posts/index.tmpl", gin.H{
+      "title": "Posts",
+    })
+  })
+  router.GET("/users/index", func(c *gin.Context) {
+    c.HTML(http.StatusOK, "users/index.tmpl", gin.H{
+      "title": "Users",
+    })
+  })
+  router.Run(":8080")
 }
 ```
 
@@ -1361,7 +1379,7 @@ templates/posts/index.tmpl
 ```html
 {{ define "posts/index.tmpl" }}
 <html><h1>
-	{{ .title }}
+  {{ .title }}
 </h1>
 <p>Using posts/index.tmpl</p>
 </html>
@@ -1373,7 +1391,7 @@ templates/users/index.tmpl
 ```html
 {{ define "users/index.tmpl" }}
 <html><h1>
-	{{ .title }}
+  {{ .title }}
 </h1>
 <p>Using users/index.tmpl</p>
 </html>
@@ -1388,10 +1406,10 @@ You can also use your own html template render
 import "html/template"
 
 func main() {
-	router := gin.Default()
-	html := template.Must(template.ParseFiles("file1", "file2"))
-	router.SetHTMLTemplate(html)
-	router.Run(":8080")
+  router := gin.Default()
+  html := template.Must(template.ParseFiles("file1", "file2"))
+  router.SetHTMLTemplate(html)
+  router.Run(":8080")
 }
 ```
 
@@ -1400,9 +1418,9 @@ func main() {
 You may use custom delims
 
 ```go
-	r := gin.Default()
-	r.Delims("{[{", "}]}")
-	r.LoadHTMLGlob("/path/to/templates")
+  r := gin.Default()
+  r.Delims("{[{", "}]}")
+  r.LoadHTMLGlob("/path/to/templates")
 ```
 
 #### Custom Template Funcs
@@ -1452,7 +1470,8 @@ Date: {[{.now | formatAsDate}]}
 ```
 
 Result:
-```
+
+```sh
 Date: 2017/07/01
 ```
 
@@ -1466,14 +1485,15 @@ Issuing a HTTP redirect is easy. Both internal and external locations are suppor
 
 ```go
 r.GET("/test", func(c *gin.Context) {
-	c.Redirect(http.StatusMovedPermanently, "http://www.google.com/")
+  c.Redirect(http.StatusMovedPermanently, "http://www.google.com/")
 })
 ```
 
 Issuing a HTTP redirect from POST. Refer to issue: [#444](https://github.com/gin-gonic/gin/issues/444)
+
 ```go
 r.POST("/test", func(c *gin.Context) {
-	c.Redirect(http.StatusFound, "/foo")
+  c.Redirect(http.StatusFound, "/foo")
 })
 ```
 
@@ -1489,44 +1509,43 @@ r.GET("/test2", func(c *gin.Context) {
 })
 ```
 
-
 ### Custom Middleware
 
 ```go
 func Logger() gin.HandlerFunc {
-	return func(c *gin.Context) {
-		t := time.Now()
+  return func(c *gin.Context) {
+    t := time.Now()
 
-		// Set example variable
-		c.Set("example", "12345")
+    // Set example variable
+    c.Set("example", "12345")
 
-		// before request
+    // before request
 
-		c.Next()
+    c.Next()
 
-		// after request
-		latency := time.Since(t)
-		log.Print(latency)
+    // after request
+    latency := time.Since(t)
+    log.Print(latency)
 
-		// access the status we are sending
-		status := c.Writer.Status()
-		log.Println(status)
-	}
+    // access the status we are sending
+    status := c.Writer.Status()
+    log.Println(status)
+  }
 }
 
 func main() {
-	r := gin.New()
-	r.Use(Logger())
+  r := gin.New()
+  r.Use(Logger())
 
-	r.GET("/test", func(c *gin.Context) {
-		example := c.MustGet("example").(string)
+  r.GET("/test", func(c *gin.Context) {
+    example := c.MustGet("example").(string)
 
-		// it would print: "12345"
-		log.Println(example)
-	})
+    // it would print: "12345"
+    log.Println(example)
+  })
 
-	// Listen and serve on 0.0.0.0:8080
-	r.Run(":8080")
+  // Listen and serve on 0.0.0.0:8080
+  r.Run(":8080")
 }
 ```
 
@@ -1535,37 +1554,37 @@ func main() {
 ```go
 // simulate some private data
 var secrets = gin.H{
-	"foo":    gin.H{"email": "foo@bar.com", "phone": "123433"},
-	"austin": gin.H{"email": "austin@example.com", "phone": "666"},
-	"lena":   gin.H{"email": "lena@guapa.com", "phone": "523443"},
+  "foo":    gin.H{"email": "foo@bar.com", "phone": "123433"},
+  "austin": gin.H{"email": "austin@example.com", "phone": "666"},
+  "lena":   gin.H{"email": "lena@guapa.com", "phone": "523443"},
 }
 
 func main() {
-	r := gin.Default()
-
-	// Group using gin.BasicAuth() middleware
-	// gin.Accounts is a shortcut for map[string]string
-	authorized := r.Group("/admin", gin.BasicAuth(gin.Accounts{
-		"foo":    "bar",
-		"austin": "1234",
-		"lena":   "hello2",
-		"manu":   "4321",
-	}))
-
-	// /admin/secrets endpoint
-	// hit "localhost:8080/admin/secrets
-	authorized.GET("/secrets", func(c *gin.Context) {
-		// get user, it was set by the BasicAuth middleware
-		user := c.MustGet(gin.AuthUserKey).(string)
-		if secret, ok := secrets[user]; ok {
-			c.JSON(http.StatusOK, gin.H{"user": user, "secret": secret})
-		} else {
-			c.JSON(http.StatusOK, gin.H{"user": user, "secret": "NO SECRET :("})
-		}
-	})
-
-	// Listen and serve on 0.0.0.0:8080
-	r.Run(":8080")
+  r := gin.Default()
+
+  // Group using gin.BasicAuth() middleware
+  // gin.Accounts is a shortcut for map[string]string
+  authorized := r.Group("/admin", gin.BasicAuth(gin.Accounts{
+    "foo":    "bar",
+    "austin": "1234",
+    "lena":   "hello2",
+    "manu":   "4321",
+  }))
+
+  // /admin/secrets endpoint
+  // hit "localhost:8080/admin/secrets
+  authorized.GET("/secrets", func(c *gin.Context) {
+    // get user, it was set by the BasicAuth middleware
+    user := c.MustGet(gin.AuthUserKey).(string)
+    if secret, ok := secrets[user]; ok {
+      c.JSON(http.StatusOK, gin.H{"user": user, "secret": secret})
+    } else {
+      c.JSON(http.StatusOK, gin.H{"user": user, "secret": "NO SECRET :("})
+    }
+  })
+
+  // Listen and serve on 0.0.0.0:8080
+  r.Run(":8080")
 }
 ```
 
@@ -1575,30 +1594,30 @@ When starting new Goroutines inside a middleware or handler, you **SHOULD NOT**
 
 ```go
 func main() {
-	r := gin.Default()
+  r := gin.Default()
 
-	r.GET("/long_async", func(c *gin.Context) {
-		// create copy to be used inside the goroutine
-		cCp := c.Copy()
-		go func() {
-			// simulate a long task with time.Sleep(). 5 seconds
-			time.Sleep(5 * time.Second)
+  r.GET("/long_async", func(c *gin.Context) {
+    // create copy to be used inside the goroutine
+    cCp := c.Copy()
+    go func() {
+      // simulate a long task with time.Sleep(). 5 seconds
+      time.Sleep(5 * time.Second)
 
-			// note that you are using the copied context "cCp", IMPORTANT
-			log.Println("Done! in path " + cCp.Request.URL.Path)
-		}()
-	})
+      // note that you are using the copied context "cCp", IMPORTANT
+      log.Println("Done! in path " + cCp.Request.URL.Path)
+    }()
+  })
 
-	r.GET("/long_sync", func(c *gin.Context) {
-		// simulate a long task with time.Sleep(). 5 seconds
-		time.Sleep(5 * time.Second)
+  r.GET("/long_sync", func(c *gin.Context) {
+    // simulate a long task with time.Sleep(). 5 seconds
+    time.Sleep(5 * time.Second)
 
-		// since we are NOT using a goroutine, we do not have to copy the context
-		log.Println("Done! in path " + c.Request.URL.Path)
-	})
+    // since we are NOT using a goroutine, we do not have to copy the context
+    log.Println("Done! in path " + c.Request.URL.Path)
+  })
 
-	// Listen and serve on 0.0.0.0:8080
-	r.Run(":8080")
+  // Listen and serve on 0.0.0.0:8080
+  r.Run(":8080")
 }
 ```
 
@@ -1608,24 +1627,25 @@ Use `http.ListenAndServe()` directly, like this:
 
 ```go
 func main() {
-	router := gin.Default()
-	http.ListenAndServe(":8080", router)
+  router := gin.Default()
+  http.ListenAndServe(":8080", router)
 }
 ```
+
 or
 
 ```go
 func main() {
-	router := gin.Default()
-
-	s := &http.Server{
-		Addr:           ":8080",
-		Handler:        router,
-		ReadTimeout:    10 * time.Second,
-		WriteTimeout:   10 * time.Second,
-		MaxHeaderBytes: 1 << 20,
-	}
-	s.ListenAndServe()
+  router := gin.Default()
+
+  s := &http.Server{
+    Addr:           ":8080",
+    Handler:        router,
+    ReadTimeout:    10 * time.Second,
+    WriteTimeout:   10 * time.Second,
+    MaxHeaderBytes: 1 << 20,
+  }
+  s.ListenAndServe()
 }
 ```
 
@@ -1637,22 +1657,22 @@ example for 1-line LetsEncrypt HTTPS servers.
 package main
 
 import (
-	"log"
-	"net/http"
+  "log"
+  "net/http"
 
-	"github.com/gin-gonic/autotls"
-	"github.com/gin-gonic/gin"
+  "github.com/gin-gonic/autotls"
+  "github.com/gin-gonic/gin"
 )
 
 func main() {
-	r := gin.Default()
+  r := gin.Default()
 
-	// Ping handler
-	r.GET("/ping", func(c *gin.Context) {
-		c.String(http.StatusOK, "pong")
-	})
+  // Ping handler
+  r.GET("/ping", func(c *gin.Context) {
+    c.String(http.StatusOK, "pong")
+  })
 
-	log.Fatal(autotls.Run(r, "example1.com", "example2.com"))
+  log.Fatal(autotls.Run(r, "example1.com", "example2.com"))
 }
 ```
 
@@ -1662,29 +1682,29 @@ example for custom autocert manager.
 package main
 
 import (
-	"log"
-	"net/http"
+  "log"
+  "net/http"
 
-	"github.com/gin-gonic/autotls"
-	"github.com/gin-gonic/gin"
-	"golang.org/x/crypto/acme/autocert"
+  "github.com/gin-gonic/autotls"
+  "github.com/gin-gonic/gin"
+  "golang.org/x/crypto/acme/autocert"
 )
 
 func main() {
-	r := gin.Default()
+  r := gin.Default()
 
-	// Ping handler
-	r.GET("/ping", func(c *gin.Context) {
-		c.String(http.StatusOK, "pong")
-	})
+  // Ping handler
+  r.GET("/ping", func(c *gin.Context) {
+    c.String(http.StatusOK, "pong")
+  })
 
-	m := autocert.Manager{
-		Prompt:     autocert.AcceptTOS,
-		HostPolicy: autocert.HostWhitelist("example1.com", "example2.com"),
-		Cache:      autocert.DirCache("/var/www/.cache"),
-	}
+  m := autocert.Manager{
+    Prompt:     autocert.AcceptTOS,
+    HostPolicy: autocert.HostWhitelist("example1.com", "example2.com"),
+    Cache:      autocert.DirCache("/var/www/.cache"),
+  }
 
-	log.Fatal(autotls.RunWithManager(r, &m))
+  log.Fatal(autotls.RunWithManager(r, &m))
 }
 ```
 
@@ -1696,84 +1716,84 @@ See the [question](https://github.com/gin-gonic/gin/issues/346) and try the foll
 package main
 
 import (
-	"log"
-	"net/http"
-	"time"
+  "log"
+  "net/http"
+  "time"
 
-	"github.com/gin-gonic/gin"
-	"golang.org/x/sync/errgroup"
+  "github.com/gin-gonic/gin"
+  "golang.org/x/sync/errgroup"
 )
 
 var (
-	g errgroup.Group
+  g errgroup.Group
 )
 
 func router01() http.Handler {
-	e := gin.New()
-	e.Use(gin.Recovery())
-	e.GET("/", func(c *gin.Context) {
-		c.JSON(
-			http.StatusOK,
-			gin.H{
-				"code":  http.StatusOK,
-				"error": "Welcome server 01",
-			},
-		)
-	})
+  e := gin.New()
+  e.Use(gin.Recovery())
+  e.GET("/", func(c *gin.Context) {
+    c.JSON(
+      http.StatusOK,
+      gin.H{
+        "code":  http.StatusOK,
+        "error": "Welcome server 01",
+      },
+    )
+  })
 
-	return e
+  return e
 }
 
 func router02() http.Handler {
-	e := gin.New()
-	e.Use(gin.Recovery())
-	e.GET("/", func(c *gin.Context) {
-		c.JSON(
-			http.StatusOK,
-			gin.H{
-				"code":  http.StatusOK,
-				"error": "Welcome server 02",
-			},
-		)
-	})
+  e := gin.New()
+  e.Use(gin.Recovery())
+  e.GET("/", func(c *gin.Context) {
+    c.JSON(
+      http.StatusOK,
+      gin.H{
+        "code":  http.StatusOK,
+        "error": "Welcome server 02",
+      },
+    )
+  })
 
-	return e
+  return e
 }
 
 func main() {
-	server01 := &http.Server{
-		Addr:         ":8080",
-		Handler:      router01(),
-		ReadTimeout:  5 * time.Second,
-		WriteTimeout: 10 * time.Second,
-	}
-
-	server02 := &http.Server{
-		Addr:         ":8081",
-		Handler:      router02(),
-		ReadTimeout:  5 * time.Second,
-		WriteTimeout: 10 * time.Second,
-	}
-
-	g.Go(func() error {
-		err := server01.ListenAndServe()
-		if err != nil && err != http.ErrServerClosed {
-			log.Fatal(err)
-		}
-		return err
-	})
-
-	g.Go(func() error {
-		err := server02.ListenAndServe()
-		if err != nil && err != http.ErrServerClosed {
-			log.Fatal(err)
-		}
-		return err
-	})
-
-	if err := g.Wait(); err != nil {
-		log.Fatal(err)
-	}
+  server01 := &http.Server{
+    Addr:         ":8080",
+    Handler:      router01(),
+    ReadTimeout:  5 * time.Second,
+    WriteTimeout: 10 * time.Second,
+  }
+
+  server02 := &http.Server{
+    Addr:         ":8081",
+    Handler:      router02(),
+    ReadTimeout:  5 * time.Second,
+    WriteTimeout: 10 * time.Second,
+  }
+
+  g.Go(func() error {
+    err := server01.ListenAndServe()
+    if err != nil && err != http.ErrServerClosed {
+      log.Fatal(err)
+    }
+    return err
+  })
+
+  g.Go(func() error {
+    err := server02.ListenAndServe()
+    if err != nil && err != http.ErrServerClosed {
+      log.Fatal(err)
+    }
+    return err
+  })
+
+  if err := g.Wait(); err != nil {
+    log.Fatal(err)
+  }
 }
 ```
 
@@ -1794,9 +1814,9 @@ endless.ListenAndServe(":4242", router)
 
 Alternatives:
 
-* [manners](https://github.com/braintree/manners): A polite Go HTTP server that shuts down gracefully.
-* [graceful](https://github.com/tylerb/graceful): Graceful is a Go package enabling graceful shutdown of an http.Handler server.
 * [grace](https://github.com/facebookgo/grace): Graceful restart & zero downtime deploy for Go servers.
+* [graceful](https://github.com/tylerb/graceful): Graceful is a Go package enabling graceful shutdown of an http.Handler server.
+* [manners](https://github.com/braintree/manners): A polite Go HTTP server that shuts down gracefully.
 
 #### Manually
 
@@ -1808,57 +1828,57 @@ In case you are using Go 1.8 or a later version, you may not need to use those l
 package main
 
 import (
-	"context"
-	"log"
-	"net/http"
-	"os"
-	"os/signal"
-	"syscall"
-	"time"
-
-	"github.com/gin-gonic/gin"
+  "context"
+  "log"
+  "net/http"
+  "os"
+  "os/signal"
+  "syscall"
+  "time"
+
+  "github.com/gin-gonic/gin"
 )
 
 func main() {
-	router := gin.Default()
-	router.GET("/", func(c *gin.Context) {
-		time.Sleep(5 * time.Second)
-		c.String(http.StatusOK, "Welcome Gin Server")
-	})
-
-	srv := &http.Server{
-		Addr:    ":8080",
-		Handler: router,
-	}
-
-	// Initializing the server in a goroutine so that
-	// it won't block the graceful shutdown handling below
-	go func() {
-		if err := srv.ListenAndServe(); err != nil && errors.Is(err, http.ErrServerClosed) {
-			log.Printf("listen: %s\n", err)
-		}
-	}()
-
-	// Wait for interrupt signal to gracefully shutdown the server with
-	// a timeout of 5 seconds.
-	quit := make(chan os.Signal)
-	// kill (no param) default send syscall.SIGTERM
-	// kill -2 is syscall.SIGINT
-	// kill -9 is syscall.SIGKILL but can't be caught, so don't need to add it
-	signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
-	<-quit
-	log.Println("Shutting down server...")
-
-	// The context is used to inform the server it has 5 seconds to finish
-	// the request it is currently handling
-	ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
-	defer cancel()
-
-	if err := srv.Shutdown(ctx); err != nil {
-		log.Fatal("Server forced to shutdown:", err)
-	}
-
-	log.Println("Server exiting")
+  router := gin.Default()
+  router.GET("/", func(c *gin.Context) {
+    time.Sleep(5 * time.Second)
+    c.String(http.StatusOK, "Welcome Gin Server")
+  })
+
+  srv := &http.Server{
+    Addr:    ":8080",
+    Handler: router,
+  }
+
+  // Initializing the server in a goroutine so that
+  // it won't block the graceful shutdown handling below
+  go func() {
+    if err := srv.ListenAndServe(); err != nil && errors.Is(err, http.ErrServerClosed) {
+      log.Printf("listen: %s\n", err)
+    }
+  }()
+
+  // Wait for interrupt signal to gracefully shutdown the server with
+  // a timeout of 5 seconds.
+  quit := make(chan os.Signal)
+  // kill (no param) default send syscall.SIGTERM
+  // kill -2 is syscall.SIGINT
+  // kill -9 is syscall.SIGKILL but can't be caught, so don't need to add it
+  signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
+  <-quit
+  log.Println("Shutting down server...")
+
+  // The context is used to inform the server it has 5 seconds to finish
+  // the request it is currently handling
+  ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
+  defer cancel()
+
+  if err := srv.Shutdown(ctx); err != nil {
+    log.Fatal("Server forced to shutdown:", err)
+  }
+
+  log.Println("Server exiting")
 }
 ```
 
@@ -1870,38 +1890,38 @@ You can build a server into a single binary containing templates by using [go-as
 
 ```go
 func main() {
-	r := gin.New()
+  r := gin.New()
 
-	t, err := loadTemplate()
-	if err != nil {
-		panic(err)
-	}
-	r.SetHTMLTemplate(t)
+  t, err := loadTemplate()
+  if err != nil {
+    panic(err)
+  }
+  r.SetHTMLTemplate(t)
 
-	r.GET("/", func(c *gin.Context) {
-		c.HTML(http.StatusOK, "/html/index.tmpl",nil)
-	})
-	r.Run(":8080")
+  r.GET("/", func(c *gin.Context) {
+    c.HTML(http.StatusOK, "/html/index.tmpl",nil)
+  })
+  r.Run(":8080")
 }
 
 // loadTemplate loads templates embedded by go-assets-builder
 func loadTemplate() (*template.Template, error) {
-	t := template.New("")
-	for name, file := range Assets.Files {
-		defer file.Close()
-		if file.IsDir() || !strings.HasSuffix(name, ".tmpl") {
-			continue
-		}
-		h, err := ioutil.ReadAll(file)
-		if err != nil {
-			return nil, err
-		}
-		t, err = t.New(name).Parse(string(h))
-		if err != nil {
-			return nil, err
-		}
-	}
-	return t, nil
+  t := template.New("")
+  for name, file := range Assets.Files {
+    defer file.Close()
+    if file.IsDir() || !strings.HasSuffix(name, ".tmpl") {
+      continue
+    }
+    h, err := ioutil.ReadAll(file)
+    if err != nil {
+      return nil, err
+    }
+    t, err = t.New(name).Parse(string(h))
+    if err != nil {
+      return nil, err
+    }
+  }
+  return t, nil
 }
 ```
 
@@ -1972,7 +1992,7 @@ func main() {
 
 Using the command `curl` command result:
 
-```
+```sh
 $ curl "http://localhost:8080/getb?field_a=hello&field_b=world"
 {"a":{"FieldA":"hello"},"b":"world"}
 $ curl "http://localhost:8080/getc?field_a=hello&field_c=world"
@@ -2031,10 +2051,10 @@ func SomeHandler(c *gin.Context) {
 }
 ```
 
-* `c.ShouldBindBodyWith` stores body into the context before binding. This has
+1. `c.ShouldBindBodyWith` stores body into the context before binding. This has
 a slight impact to performance, so you should not use this method if you are
 enough to call binding at once.
-* This feature is only needed for some formats -- `JSON`, `XML`, `MsgPack`,
+2. This feature is only needed for some formats -- `JSON`, `XML`, `MsgPack`,
 `ProtoBuf`. For other formats, `Query`, `Form`, `FormPost`, `FormMultipart`,
 can be called by `c.ShouldBind()` multiple times without any damage to
 performance (See [#1341](https://github.com/gin-gonic/gin/pull/1341)).
@@ -2043,54 +2063,54 @@ performance (See [#1341](https://github.com/gin-gonic/gin/pull/1341)).
 
 ```go
 const (
-	customerTag = "url"
-	defaultMemory = 32 << 20
+  customerTag = "url"
+  defaultMemory = 32 << 20
 )
 
 type customerBinding struct {}
 
 func (customerBinding) Name() string {
-	return "form"
+  return "form"
 }
 
 func (customerBinding) Bind(req *http.Request, obj interface{}) error {
-	if err := req.ParseForm(); err != nil {
-		return err
-	}
-	if err := req.ParseMultipartForm(defaultMemory); err != nil {
-		if err != http.ErrNotMultipart {
-			return err
-		}
-	}
-	if err := binding.MapFormWithTag(obj, req.Form, customerTag); err != nil {
-		return err
-	}
-	return validate(obj)
+  if err := req.ParseForm(); err != nil {
+    return err
+  }
+  if err := req.ParseMultipartForm(defaultMemory); err != nil {
+    if err != http.ErrNotMultipart {
+      return err
+    }
+  }
+  if err := binding.MapFormWithTag(obj, req.Form, customerTag); err != nil {
+    return err
+  }
+  return validate(obj)
 }
 
 func validate(obj interface{}) error {
-	if binding.Validator == nil {
-		return nil
-	}
-	return binding.Validator.ValidateStruct(obj)
+  if binding.Validator == nil {
+    return nil
+  }
+  return binding.Validator.ValidateStruct(obj)
 }
 
 // Now we can do this!!!
-// FormA is a external type that we can't modify it's tag
+// FormA is an external type that we can't modify it's tag
 type FormA struct {
-	FieldA string `url:"field_a"`
+  FieldA string `url:"field_a"`
 }
 
 func ListHandler(s *Service) func(ctx *gin.Context) {
-	return func(ctx *gin.Context) {
-		var urlBinding = customerBinding{}
-		var opt FormA
-		err := ctx.MustBindWith(&opt, urlBinding)
-		if err != nil {
-			...
-		}
-		...
-	}
+  return func(ctx *gin.Context) {
+    var urlBinding = customerBinding{}
+    var opt FormA
+    err := ctx.MustBindWith(&opt, urlBinding)
+    if err != nil {
+      ...
+    }
+    ...
+  }
 }
 ```
 
@@ -2102,11 +2122,11 @@ http.Pusher is supported only **go1.8+**. See the [golang blog](https://blog.gol
 package main
 
 import (
-	"html/template"
-	"log"
-	"net/http"
+  "html/template"
+  "log"
+  "net/http"
 
-	"github.com/gin-gonic/gin"
+  "github.com/gin-gonic/gin"
 )
 
 var html = template.Must(template.New("https").Parse(`
@@ -2122,31 +2142,32 @@ var html = template.Must(template.New("https").Parse(`
 `))
 
 func main() {
-	r := gin.Default()
-	r.Static("/assets", "./assets")
-	r.SetHTMLTemplate(html)
-
-	r.GET("/", func(c *gin.Context) {
-		if pusher := c.Writer.Pusher(); pusher != nil {
-			// use pusher.Push() to do server push
-			if err := pusher.Push("/assets/app.js", nil); err != nil {
-				log.Printf("Failed to push: %v", err)
-			}
-		}
-		c.HTML(http.StatusOK, "https", gin.H{
-			"status": "success",
-		})
-	})
+  r := gin.Default()
+  r.Static("/assets", "./assets")
+  r.SetHTMLTemplate(html)
+
+  r.GET("/", func(c *gin.Context) {
+    if pusher := c.Writer.Pusher(); pusher != nil {
+      // use pusher.Push() to do server push
+      if err := pusher.Push("/assets/app.js", nil); err != nil {
+        log.Printf("Failed to push: %v", err)
+      }
+    }
+    c.HTML(http.StatusOK, "https", gin.H{
+      "status": "success",
+    })
+  })
 
-	// Listen and Server in https://127.0.0.1:8080
-	r.RunTLS(":8080", "./testdata/server.pem", "./testdata/server.key")
+  // Listen and Server in https://127.0.0.1:8080
+  r.RunTLS(":8080", "./testdata/server.pem", "./testdata/server.key")
 }
 ```
 
 ### Define format for the log of routes
 
 The default log of routes is:
-```
+
+```sh
 [GIN-debug] POST   /foo                      --> main.main.func1 (3 handlers)
 [GIN-debug] GET    /bar                      --> main.main.func2 (3 handlers)
 [GIN-debug] GET    /status                   --> main.main.func3 (3 handlers)
@@ -2154,34 +2175,35 @@ The default log of routes is:
 
 If you want to log this information in given format (e.g. JSON, key values or something else), then you can define this format with `gin.DebugPrintRouteFunc`.
 In the example below, we log all routes with standard log package but you can use another log tools that suits of your needs.
+
 ```go
 import (
-	"log"
-	"net/http"
+  "log"
+  "net/http"
 
-	"github.com/gin-gonic/gin"
+  "github.com/gin-gonic/gin"
 )
 
 func main() {
-	r := gin.Default()
-	gin.DebugPrintRouteFunc = func(httpMethod, absolutePath, handlerName string, nuHandlers int) {
-		log.Printf("endpoint %v %v %v %v\n", httpMethod, absolutePath, handlerName, nuHandlers)
-	}
+  r := gin.Default()
+  gin.DebugPrintRouteFunc = func(httpMethod, absolutePath, handlerName string, nuHandlers int) {
+    log.Printf("endpoint %v %v %v %v\n", httpMethod, absolutePath, handlerName, nuHandlers)
+  }
 
-	r.POST("/foo", func(c *gin.Context) {
-		c.JSON(http.StatusOK, "foo")
-	})
+  r.POST("/foo", func(c *gin.Context) {
+    c.JSON(http.StatusOK, "foo")
+  })
 
-	r.GET("/bar", func(c *gin.Context) {
-		c.JSON(http.StatusOK, "bar")
-	})
+  r.GET("/bar", func(c *gin.Context) {
+    c.JSON(http.StatusOK, "bar")
+  })
 
-	r.GET("/status", func(c *gin.Context) {
-		c.JSON(http.StatusOK, "ok")
-	})
+  r.GET("/status", func(c *gin.Context) {
+    c.JSON(http.StatusOK, "ok")
+  })
 
-	// Listen and Server in http://0.0.0.0:8080
-	r.Run()
+  // Listen and Server in http://0.0.0.0:8080
+  r.Run()
 }
 ```
 
@@ -2233,52 +2255,53 @@ unnecessary computation.
 
 ```go
 import (
-	"fmt"
+  "fmt"
 
-	"github.com/gin-gonic/gin"
+  "github.com/gin-gonic/gin"
 )
 
 func main() {
 
-	router := gin.Default()
-	router.SetTrustedProxies([]string{"192.168.1.2"})
+  router := gin.Default()
+  router.SetTrustedProxies([]string{"192.168.1.2"})
 
-	router.GET("/", func(c *gin.Context) {
-		// If the client is 192.168.1.2, use the X-Forwarded-For
-		// header to deduce the original client IP from the trust-
-		// worthy parts of that header.
-		// Otherwise, simply return the direct client IP
-		fmt.Printf("ClientIP: %s\n", c.ClientIP())
-	})
-	router.Run()
+  router.GET("/", func(c *gin.Context) {
+    // If the client is 192.168.1.2, use the X-Forwarded-For
+    // header to deduce the original client IP from the trust-
+    // worthy parts of that header.
+    // Otherwise, simply return the direct client IP
+    fmt.Printf("ClientIP: %s\n", c.ClientIP())
+  })
+  router.Run()
 }
 ```
 
 **Notice:** If you are using a CDN service, you can set the `Engine.TrustedPlatform`
 to skip TrustedProxies check, it has a higher priority than TrustedProxies. 
 Look at the example below:
+
 ```go
 import (
-	"fmt"
+  "fmt"
 
-	"github.com/gin-gonic/gin"
+  "github.com/gin-gonic/gin"
 )
 
 func main() {
 
-	router := gin.Default()
-	// Use predefined header gin.PlatformXXX
-	router.TrustedPlatform = gin.PlatformGoogleAppEngine
-	// Or set your own trusted request header for another trusted proxy service
-	// Don't set it to any suspect request header, it's unsafe
-	router.TrustedPlatform = "X-CDN-IP"
+  router := gin.Default()
+  // Use predefined header gin.PlatformXXX
+  router.TrustedPlatform = gin.PlatformGoogleAppEngine
+  // Or set your own trusted request header for another trusted proxy service
+  // Don't set it to any suspect request header, it's unsafe
+  router.TrustedPlatform = "X-CDN-IP"
 
-	router.GET("/", func(c *gin.Context) {
-		// If you set TrustedPlatform, ClientIP() will resolve the
-		// corresponding header and return IP directly
-		fmt.Printf("ClientIP: %s\n", c.ClientIP())
-	})
-	router.Run()
+  router.GET("/", func(c *gin.Context) {
+    // If you set TrustedPlatform, ClientIP() will resolve the
+    // corresponding header and return IP directly
+    fmt.Printf("ClientIP: %s\n", c.ClientIP())
+  })
+  router.Run()
 }
 ```
 
@@ -2290,22 +2313,22 @@ The `net/http/httptest` package is preferable way for HTTP testing.
 package main
 
 import (
-	"net/http"
+  "net/http"
 
-	"github.com/gin-gonic/gin"
+  "github.com/gin-gonic/gin"
 )
 
 func setupRouter() *gin.Engine {
-	r := gin.Default()
-	r.GET("/ping", func(c *gin.Context) {
-		c.String(http.StatusOK, "pong")
-	})
-	return r
+  r := gin.Default()
+  r.GET("/ping", func(c *gin.Context) {
+    c.String(http.StatusOK, "pong")
+  })
+  return r
 }
 
 func main() {
-	r := setupRouter()
-	r.Run(":8080")
+  r := setupRouter()
+  r.Run(":8080")
 }
 ```
 
@@ -2315,22 +2338,22 @@ Test for code example above:
 package main
 
 import (
-	"net/http"
-	"net/http/httptest"
-	"testing"
+  "net/http"
+  "net/http/httptest"
+  "testing"
 
-	"github.com/stretchr/testify/assert"
+  "github.com/stretchr/testify/assert"
 )
 
 func TestPingRoute(t *testing.T) {
-	router := setupRouter()
+  router := setupRouter()
 
-	w := httptest.NewRecorder()
-	req, _ := http.NewRequest(http.MethodGet, "/ping", nil)
-	router.ServeHTTP(w, req)
+  w := httptest.NewRecorder()
+  req, _ := http.NewRequest(http.MethodGet, "/ping", nil)
+  router.ServeHTTP(w, req)
 
-	assert.Equal(t, http.StatusOK, w.Code)
-	assert.Equal(t, "pong", w.Body.String())
+  assert.Equal(t, http.StatusOK, w.Code)
+  assert.Equal(t, "pong", w.Body.String())
 }
 ```
 
@@ -2345,4 +2368,3 @@ Awesome project lists using [Gin](https://github.com/gin-gonic/gin) web framewor
 * [picfit](https://github.com/thoas/picfit): An image resizing server written in Go.
 * [brigade](https://github.com/brigadecore/brigade): Event-based Scripting for Kubernetes.
 * [dkron](https://github.com/distribworks/dkron): Distributed, fault tolerant job scheduling system.
-
diff --git a/binding/default_validator.go b/binding/default_validator.go
index c03afe7..e216b85 100644
--- a/binding/default_validator.go
+++ b/binding/default_validator.go
@@ -43,7 +43,7 @@ func (err SliceValidationError) Error() string {
 	}
 }
 
-var _ StructValidator = &defaultValidator{}
+var _ StructValidator = (*defaultValidator)(nil)
 
 // ValidateStruct receives any kind of type, but only performed struct or pointer to struct type.
 func (v *defaultValidator) ValidateStruct(obj any) error {
diff --git a/binding/form_mapping.go b/binding/form_mapping.go
index 98cebfe..540bbbb 100644
--- a/binding/form_mapping.go
+++ b/binding/form_mapping.go
@@ -19,7 +19,7 @@ import (
 var (
 	errUnknownType = errors.New("unknown type")
 
-	// ErrConvertMapStringSlice can not covert to map[string][]string
+	// ErrConvertMapStringSlice can not convert to map[string][]string
 	ErrConvertMapStringSlice = errors.New("can not convert to map slices of strings")
 
 	// ErrConvertToMapString can not convert to map[string]string
diff --git a/context.go b/context.go
index 46bf113..b66b8ad 100644
--- a/context.go
+++ b/context.go
@@ -15,6 +15,7 @@ import (
 	"net/http"
 	"net/url"
 	"os"
+	"path/filepath"
 	"strings"
 	"sync"
 	"time"
@@ -153,9 +154,10 @@ func (c *Context) Handler() HandlerFunc {
 
 // FullPath returns a matched route full path. For not found routes
 // returns an empty string.
-//     router.GET("/user/:id", func(c *gin.Context) {
-//         c.FullPath() == "/user/:id" // true
-//     })
+//
+//	router.GET("/user/:id", func(c *gin.Context) {
+//	    c.FullPath() == "/user/:id" // true
+//	})
 func (c *Context) FullPath() string {
 	return c.fullPath
 }
@@ -382,10 +384,11 @@ func (c *Context) GetStringMapStringSlice(key string) (smss map[string][]string)
 
 // Param returns the value of the URL param.
 // It is a shortcut for c.Params.ByName(key)
-//     router.GET("/user/:id", func(c *gin.Context) {
-//         // a GET request to /user/john
-//         id := c.Param("id") // id == "john"
-//     })
+//
+//	router.GET("/user/:id", func(c *gin.Context) {
+//	    // a GET request to /user/john
+//	    id := c.Param("id") // id == "john"
+//	})
 func (c *Context) Param(key string) string {
 	return c.Params.ByName(key)
 }
@@ -402,11 +405,12 @@ func (c *Context) AddParam(key, value string) {
 // Query returns the keyed url query value if it exists,
 // otherwise it returns an empty string `("")`.
 // It is shortcut for `c.Request.URL.Query().Get(key)`
-//     GET /path?id=1234&name=Manu&value=
-// 	   c.Query("id") == "1234"
-// 	   c.Query("name") == "Manu"
-// 	   c.Query("value") == ""
-// 	   c.Query("wtf") == ""
+//
+//	    GET /path?id=1234&name=Manu&value=
+//		   c.Query("id") == "1234"
+//		   c.Query("name") == "Manu"
+//		   c.Query("value") == ""
+//		   c.Query("wtf") == ""
 func (c *Context) Query(key string) (value string) {
 	value, _ = c.GetQuery(key)
 	return
@@ -415,10 +419,11 @@ func (c *Context) Query(key string) (value string) {
 // DefaultQuery returns the keyed url query value if it exists,
 // otherwise it returns the specified defaultValue string.
 // See: Query() and GetQuery() for further information.
-//     GET /?name=Manu&lastname=
-//     c.DefaultQuery("name", "unknown") == "Manu"
-//     c.DefaultQuery("id", "none") == "none"
-//     c.DefaultQuery("lastname", "none") == ""
+//
+//	GET /?name=Manu&lastname=
+//	c.DefaultQuery("name", "unknown") == "Manu"
+//	c.DefaultQuery("id", "none") == "none"
+//	c.DefaultQuery("lastname", "none") == ""
 func (c *Context) DefaultQuery(key, defaultValue string) string {
 	if value, ok := c.GetQuery(key); ok {
 		return value
@@ -430,10 +435,11 @@ func (c *Context) DefaultQuery(key, defaultValue string) string {
 // if it exists `(value, true)` (even when the value is an empty string),
 // otherwise it returns `("", false)`.
 // It is shortcut for `c.Request.URL.Query().Get(key)`
-//     GET /?name=Manu&lastname=
-//     ("Manu", true) == c.GetQuery("name")
-//     ("", false) == c.GetQuery("id")
-//     ("", true) == c.GetQuery("lastname")
+//
+//	GET /?name=Manu&lastname=
+//	("Manu", true) == c.GetQuery("name")
+//	("", false) == c.GetQuery("id")
+//	("", true) == c.GetQuery("lastname")
 func (c *Context) GetQuery(key string) (string, bool) {
 	if values, ok := c.GetQueryArray(key); ok {
 		return values[0], ok
@@ -500,9 +506,10 @@ func (c *Context) DefaultPostForm(key, defaultValue string) string {
 // form or multipart form when it exists `(value, true)` (even when the value is an empty string),
 // otherwise it returns ("", false).
 // For example, during a PATCH request to update the user's email:
-//     email=mail@example.com  -->  ("mail@example.com", true) := GetPostForm("email") // set email to "mail@example.com"
-// 	   email=                  -->  ("", true) := GetPostForm("email") // set email to ""
-//                             -->  ("", false) := GetPostForm("email") // do nothing with email
+//
+//	    email=mail@example.com  -->  ("mail@example.com", true) := GetPostForm("email") // set email to "mail@example.com"
+//		   email=                  -->  ("", true) := GetPostForm("email") // set email to ""
+//	                            -->  ("", false) := GetPostForm("email") // do nothing with email
 func (c *Context) GetPostForm(key string) (string, bool) {
 	if values, ok := c.GetPostFormArray(key); ok {
 		return values[0], ok
@@ -595,6 +602,10 @@ func (c *Context) SaveUploadedFile(file *multipart.FileHeader, dst string) error
 	}
 	defer src.Close()
 
+	if err = os.MkdirAll(filepath.Dir(dst), 0750); err != nil {
+		return err
+	}
+
 	out, err := os.Create(dst)
 	if err != nil {
 		return err
@@ -607,8 +618,10 @@ func (c *Context) SaveUploadedFile(file *multipart.FileHeader, dst string) error
 
 // Bind checks the Method and Content-Type to select a binding engine automatically,
 // Depending on the "Content-Type" header different bindings are used, for example:
-//     "application/json" --> JSON binding
-//     "application/xml"  --> XML binding
+//
+//	"application/json" --> JSON binding
+//	"application/xml"  --> XML binding
+//
 // It parses the request's body as JSON if Content-Type == "application/json" using JSON or XML as a JSON input.
 // It decodes the json payload into the struct specified as a pointer.
 // It writes a 400 error and sets Content-Type header "text/plain" in the response if input is not valid.
@@ -651,7 +664,7 @@ func (c *Context) BindHeader(obj any) error {
 // It will abort the request with HTTP 400 if any error occurs.
 func (c *Context) BindUri(obj any) error {
 	if err := c.ShouldBindUri(obj); err != nil {
-		c.AbortWithError(http.StatusBadRequest, err).SetType(ErrorTypeBind) // nolint: errcheck
+		c.AbortWithError(http.StatusBadRequest, err).SetType(ErrorTypeBind) //nolint: errcheck
 		return err
 	}
 	return nil
@@ -662,7 +675,7 @@ func (c *Context) BindUri(obj any) error {
 // See the binding package.
 func (c *Context) MustBindWith(obj any, b binding.Binding) error {
 	if err := c.ShouldBindWith(obj, b); err != nil {
-		c.AbortWithError(http.StatusBadRequest, err).SetType(ErrorTypeBind) // nolint: errcheck
+		c.AbortWithError(http.StatusBadRequest, err).SetType(ErrorTypeBind) //nolint: errcheck
 		return err
 	}
 	return nil
@@ -670,8 +683,10 @@ func (c *Context) MustBindWith(obj any, b binding.Binding) error {
 
 // ShouldBind checks the Method and Content-Type to select a binding engine automatically,
 // Depending on the "Content-Type" header different bindings are used, for example:
-//     "application/json" --> JSON binding
-//     "application/xml"  --> XML binding
+//
+//	"application/json" --> JSON binding
+//	"application/xml"  --> XML binding
+//
 // It parses the request's body as JSON if Content-Type == "application/json" using JSON or XML as a JSON input.
 // It decodes the json payload into the struct specified as a pointer.
 // Like c.Bind() but this method does not set the response status code to 400 or abort if input is not valid.
@@ -1112,7 +1127,7 @@ func (c *Context) Negotiate(code int, config Negotiate) {
 		c.TOML(code, data)
 
 	default:
-		c.AbortWithError(http.StatusNotAcceptable, errors.New("the accepted formats are not offered by the server")) // nolint: errcheck
+		c.AbortWithError(http.StatusNotAcceptable, errors.New("the accepted formats are not offered by the server")) //nolint: errcheck
 	}
 }
 
diff --git a/debug.go b/debug.go
index b9f8234..cbcedbc 100644
--- a/debug.go
+++ b/debug.go
@@ -12,7 +12,7 @@ import (
 	"strings"
 )
 
-const ginSupportMinGoVer = 15
+const ginSupportMinGoVer = 16
 
 // IsDebugging returns true if the framework is running in debug mode.
 // Use SetMode(gin.ReleaseMode) to disable debug mode.
@@ -67,7 +67,7 @@ func getMinVer(v string) (uint64, error) {
 
 func debugPrintWARNINGDefault() {
 	if v, e := getMinVer(runtime.Version()); e == nil && v < ginSupportMinGoVer {
-		debugPrint(`[WARNING] Now Gin requires Go 1.15+.
+		debugPrint(`[WARNING] Now Gin requires Go 1.16+.
 
 `)
 	}
diff --git a/errors.go b/errors.go
index 2853ce8..06b53c2 100644
--- a/errors.go
+++ b/errors.go
@@ -39,7 +39,7 @@ type Error struct {
 
 type errorMsgs []*Error
 
-var _ error = &Error{}
+var _ error = (*Error)(nil)
 
 // SetType sets the error's type.
 func (msg *Error) SetType(flags ErrorType) *Error {
@@ -124,10 +124,11 @@ func (a errorMsgs) Last() *Error {
 
 // Errors returns an array with all the error messages.
 // Example:
-// 		c.Error(errors.New("first"))
-// 		c.Error(errors.New("second"))
-// 		c.Error(errors.New("third"))
-// 		c.Errors.Errors() // == []string{"first", "second", "third"}
+//
+//	c.Error(errors.New("first"))
+//	c.Error(errors.New("second"))
+//	c.Error(errors.New("third"))
+//	c.Errors.Errors() // == []string{"first", "second", "third"}
 func (a errorMsgs) Errors() []string {
 	if len(a) == 0 {
 		return nil
diff --git a/gin.go b/gin.go
index f932429..35159d0 100644
--- a/gin.go
+++ b/gin.go
@@ -166,7 +166,7 @@ type Engine struct {
 	trustedCIDRs     []*net.IPNet
 }
 
-var _ IRouter = &Engine{}
+var _ IRouter = (*Engine)(nil)
 
 // New returns a new blank Engine instance without any middleware attached.
 // By default, the configuration is:
@@ -203,7 +203,7 @@ func New() *Engine {
 	}
 	engine.RouterGroup.engine = engine
 	engine.pool.New = func() any {
-		return engine.allocateContext()
+		return engine.allocateContext(engine.maxParams)
 	}
 	return engine
 }
@@ -225,8 +225,8 @@ func (engine *Engine) Handler() http.Handler {
 	return h2c.NewHandler(engine, h2s)
 }
 
-func (engine *Engine) allocateContext() *Context {
-	v := make(Params, 0, engine.maxParams)
+func (engine *Engine) allocateContext(maxParams uint16) *Context {
+	v := make(Params, 0, maxParams)
 	skippedNodes := make([]skippedNode, 0, engine.maxSections)
 	return &Context{engine: engine, params: &v, skippedNodes: &skippedNodes}
 }
diff --git a/ginS/gins.go b/ginS/gins.go
index 1550b86..ea38c61 100644
--- a/ginS/gins.go
+++ b/ginS/gins.go
@@ -108,7 +108,8 @@ func StaticFile(relativePath, filepath string) gin.IRoutes {
 // of the Router's NotFound handler.
 // To use the operating system's file system implementation,
 // use :
-//     router.Static("/static", "/var/www")
+//
+//	router.Static("/static", "/var/www")
 func Static(relativePath, root string) gin.IRoutes {
 	return engine().Static(relativePath, root)
 }
diff --git a/go.mod b/go.mod
index ae7a5f8..1c64cf1 100644
--- a/go.mod
+++ b/go.mod
@@ -3,29 +3,34 @@ module github.com/gin-gonic/gin
 go 1.18
 
 require (
+	github.com/bytedance/sonic v1.4.0
 	github.com/gin-contrib/sse v0.1.0
-	github.com/go-playground/validator/v10 v10.10.0
-	github.com/goccy/go-json v0.9.8
+	github.com/go-playground/validator/v10 v10.11.1
+	github.com/goccy/go-json v0.9.11
 	github.com/json-iterator/go v1.1.12
-	github.com/mattn/go-isatty v0.0.14
+	github.com/mattn/go-isatty v0.0.16
 	github.com/pelletier/go-toml/v2 v2.0.2
 	github.com/stretchr/testify v1.8.0
 	github.com/ugorji/go/codec v1.2.7
-	golang.org/x/net v0.0.0-20210226172049-e18ecbb05110
-	google.golang.org/protobuf v1.28.0
+	golang.org/x/net v0.0.0-20221004154528-8021a29435af
+	google.golang.org/protobuf v1.28.1
 	gopkg.in/yaml.v2 v2.4.0
 )
 
 require (
+	github.com/chenzhuoyu/base64x v0.0.0-20220526154910-8bf9453eb81a // indirect
 	github.com/davecgh/go-spew v1.1.1 // indirect
 	github.com/go-playground/locales v0.14.0 // indirect
 	github.com/go-playground/universal-translator v0.18.0 // indirect
+	github.com/klauspost/cpuid/v2 v2.0.14 // indirect
 	github.com/leodido/go-urn v1.2.1 // indirect
 	github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
 	github.com/modern-go/reflect2 v1.0.2 // indirect
 	github.com/pmezard/go-difflib v1.0.0 // indirect
-	golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 // indirect
-	golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069 // indirect
-	golang.org/x/text v0.3.6 // indirect
+	github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
+	golang.org/x/arch v0.0.0-20220412001346-fc48f9fe4c15 // indirect
+	golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 // indirect
+	golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab // indirect
+	golang.org/x/text v0.3.7 // indirect
 	gopkg.in/yaml.v3 v3.0.1 // indirect
 )
diff --git a/go.sum b/go.sum
index 3529342..35bfd2e 100644
--- a/go.sum
+++ b/go.sum
@@ -1,3 +1,8 @@
+github.com/bytedance/sonic v1.4.0 h1:d6vgPhwgHfpmEiz/9Fzea9fGzWY7RO1TQEySBiRwDLY=
+github.com/bytedance/sonic v1.4.0/go.mod h1:V973WhNhGmvHxW6nQmsHEfHaoU9F3zTF+93rH03hcUQ=
+github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY=
+github.com/chenzhuoyu/base64x v0.0.0-20220526154910-8bf9453eb81a h1:lmGPzuocwDxoPAMr9h16zoJY/USZR9jIh99nrmKk1uI=
+github.com/chenzhuoyu/base64x v0.0.0-20220526154910-8bf9453eb81a/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY=
 github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
@@ -10,16 +15,20 @@ github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb
 github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs=
 github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho=
 github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA=
-github.com/go-playground/validator/v10 v10.10.0 h1:I7mrTYv78z8k8VXa/qJlOlEXn/nBh+BF8dHX5nt/dr0=
-github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos=
-github.com/goccy/go-json v0.9.8 h1:DxXB6MLd6yyel7CLph8EwNIonUtVZd3Ue5iRcL4DQCE=
-github.com/goccy/go-json v0.9.8/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
+github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJWXmqUsHwfTRRkQ=
+github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU=
+github.com/goccy/go-json v0.9.4/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
+github.com/goccy/go-json v0.9.11 h1:/pAaQDLHEoCq/5FFmSKBswWmK6H0e8g4159Kc/X/nqk=
+github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
 github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
 github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
 github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
 github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
 github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
 github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
+github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
+github.com/klauspost/cpuid/v2 v2.0.14 h1:QRqdp6bb9M9S5yyKeYteXKuoKE4p0tGlra81fKOpWH8=
+github.com/klauspost/cpuid/v2 v2.0.14/go.mod h1:g2LTdtYhdyuGPqyWyv7qRAmj1WBqxuObKfj5c0PQa7c=
 github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
 github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
 github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
@@ -30,8 +39,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
 github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
 github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
 github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
-github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
-github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
+github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ=
+github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
 github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
 github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
 github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
@@ -53,28 +62,44 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
 github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
 github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
 github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
+github.com/tidwall/gjson v1.12.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
+github.com/tidwall/gjson v1.13.0 h1:3TFY9yxOQShrvmjdM76K+jc66zJeT6D3/VFFYCGQf7M=
+github.com/tidwall/gjson v1.13.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
+github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
+github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
+github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
+github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
+github.com/tidwall/sjson v1.2.4 h1:cuiLzLnaMeBhRmEv00Lpk3tkYrcxpmbU81tAY4Dw0tc=
+github.com/tidwall/sjson v1.2.4/go.mod h1:098SZ494YoMWPmMO6ct4dcFnqxwj9r/gF0Etp19pSNM=
+github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
+github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
 github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M=
 github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0=
 github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY=
-golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 h1:/UOmuWzQfxxo9UtlXMwuQU8CMgg1eZXqTRwkSQJWKOI=
-golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
-golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 h1:qWPm9rbaAMKs8Bq/9LRpbMqxWRVUAQwMI9fVrssnTfw=
-golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
+golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
+golang.org/x/arch v0.0.0-20220412001346-fc48f9fe4c15 h1:GVfVkciLYxn5mY5EncwAe0SXUn9Rm81rRkZ0TTmn/cU=
+golang.org/x/arch v0.0.0-20220412001346-fc48f9fe4c15/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
+golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3 h1:0es+/5331RGQPcXlMfP+WrnIIS6dNnNRe0WB02W0F4M=
+golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
+golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
+golang.org/x/net v0.0.0-20221004154528-8021a29435af h1:wv66FM3rLZGPdxpYL+ApnDe2HzHcTFta3z5nsc13wI4=
+golang.org/x/net v0.0.0-20221004154528-8021a29435af/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
 golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069 h1:siQdpVirKtzPhKl3lZWozZraCFObP8S1v6PRp0bLrtU=
 golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab h1:2QkjZIsXupsJbJIdSjjUOgWK3aEtzyuh2mPt3l/CkeU=
+golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
-golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
-golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
 golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
+golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
 golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
 golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
 golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
-google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
-google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
+google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
+google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
@@ -86,3 +111,4 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
 gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
 gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
 gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
diff --git a/internal/json/json.go b/internal/json/json.go
index a26d7db..c5f3efc 100644
--- a/internal/json/json.go
+++ b/internal/json/json.go
@@ -2,8 +2,10 @@
 // Use of this source code is governed by a MIT style
 // license that can be found in the LICENSE file.
 
-//go:build !jsoniter && !go_json
-// +build !jsoniter,!go_json
+//go:build !jsoniter && !go_json && !(sonic && avx && (linux || windows || darwin) && amd64)
+// +build !jsoniter
+// +build !go_json
+// +build !sonic !avx !linux,!windows,!darwin !amd64
 
 package json
 
diff --git a/internal/json/sonic.go b/internal/json/sonic.go
new file mode 100644
index 0000000..5a9ca4b
--- /dev/null
+++ b/internal/json/sonic.go
@@ -0,0 +1,27 @@
+// Copyright 2022 Gin Core Team. All rights reserved.
+// Use of this source code is governed by a MIT style
+// license that can be found in the LICENSE file.
+
+//go:build sonic && avx && (linux || windows || darwin) && amd64
+// +build sonic
+// +build avx
+// +build linux windows darwin
+// +build amd64
+
+package json
+
+import "github.com/bytedance/sonic"
+
+var (
+	json = sonic.ConfigStd
+	// Marshal is exported by gin/json package.
+	Marshal = json.Marshal
+	// Unmarshal is exported by gin/json package.
+	Unmarshal = json.Unmarshal
+	// MarshalIndent is exported by gin/json package.
+	MarshalIndent = json.MarshalIndent
+	// NewDecoder is exported by gin/json package.
+	NewDecoder = json.NewDecoder
+	// NewEncoder is exported by gin/json package.
+	NewEncoder = json.NewEncoder
+)
diff --git a/mode.go b/mode.go
index 545fdaa..fd26d90 100644
--- a/mode.go
+++ b/mode.go
@@ -35,8 +35,9 @@ const (
 // Note that both Logger and Recovery provides custom ways to configure their
 // output io.Writer.
 // To support coloring in Windows use:
-// 		import "github.com/mattn/go-colorable"
-// 		gin.DefaultWriter = colorable.NewColorableStdout()
+//
+//	import "github.com/mattn/go-colorable"
+//	gin.DefaultWriter = colorable.NewColorableStdout()
 var DefaultWriter io.Writer = os.Stdout
 
 // DefaultErrorWriter is the default io.Writer used by Gin to debug errors
diff --git a/path.go b/path.go
index d42d6b9..82438c1 100644
--- a/path.go
+++ b/path.go
@@ -10,12 +10,12 @@ package gin
 //
 // The following rules are applied iteratively until no further processing can
 // be done:
-//	1. Replace multiple slashes with a single slash.
-//	2. Eliminate each . path name element (the current directory).
-//	3. Eliminate each inner .. path name element (the parent directory)
-//	   along with the non-.. element that precedes it.
-//	4. Eliminate .. elements that begin a rooted path:
-//	   that is, replace "/.." by "/" at the beginning of a path.
+//  1. Replace multiple slashes with a single slash.
+//  2. Eliminate each . path name element (the current directory).
+//  3. Eliminate each inner .. path name element (the parent directory)
+//     along with the non-.. element that precedes it.
+//  4. Eliminate .. elements that begin a rooted path:
+//     that is, replace "/.." by "/" at the beginning of a path.
 //
 // If the result of this process is an empty string, "/" is returned.
 func cleanPath(p string) string {
diff --git a/recovery.go b/recovery.go
index abb6451..05b30d9 100644
--- a/recovery.go
+++ b/recovery.go
@@ -91,7 +91,7 @@ func CustomRecoveryWithWriter(out io.Writer, handle RecoveryFunc) HandlerFunc {
 				}
 				if brokenPipe {
 					// If the connection is dead, we can't write a status to it.
-					c.Error(err.(error)) // nolint: errcheck
+					c.Error(err.(error)) //nolint: errcheck
 					c.Abort()
 				} else {
 					handle(c, err)
diff --git a/response_writer.go b/response_writer.go
index 77c7ed8..43e828d 100644
--- a/response_writer.go
+++ b/response_writer.go
@@ -49,7 +49,7 @@ type responseWriter struct {
 	status int
 }
 
-var _ ResponseWriter = &responseWriter{}
+var _ ResponseWriter = (*responseWriter)(nil)
 
 func (w *responseWriter) reset(writer http.ResponseWriter) {
 	w.ResponseWriter = writer
diff --git a/routergroup.go b/routergroup.go
index 3c082d9..dfbdd7b 100644
--- a/routergroup.go
+++ b/routergroup.go
@@ -58,7 +58,7 @@ type RouterGroup struct {
 	root     bool
 }
 
-var _ IRouter = &RouterGroup{}
+var _ IRouter = (*RouterGroup)(nil)
 
 // Use adds middleware to the group, see example code in GitHub.
 func (group *RouterGroup) Use(middleware ...HandlerFunc) IRoutes {
@@ -106,37 +106,37 @@ func (group *RouterGroup) Handle(httpMethod, relativePath string, handlers ...Ha
 	return group.handle(httpMethod, relativePath, handlers)
 }
 
-// POST is a shortcut for router.Handle("POST", path, handle).
+// POST is a shortcut for router.Handle("POST", path, handlers).
 func (group *RouterGroup) POST(relativePath string, handlers ...HandlerFunc) IRoutes {
 	return group.handle(http.MethodPost, relativePath, handlers)
 }
 
-// GET is a shortcut for router.Handle("GET", path, handle).
+// GET is a shortcut for router.Handle("GET", path, handlers).
 func (group *RouterGroup) GET(relativePath string, handlers ...HandlerFunc) IRoutes {
 	return group.handle(http.MethodGet, relativePath, handlers)
 }
 
-// DELETE is a shortcut for router.Handle("DELETE", path, handle).
+// DELETE is a shortcut for router.Handle("DELETE", path, handlers).
 func (group *RouterGroup) DELETE(relativePath string, handlers ...HandlerFunc) IRoutes {
 	return group.handle(http.MethodDelete, relativePath, handlers)
 }
 
-// PATCH is a shortcut for router.Handle("PATCH", path, handle).
+// PATCH is a shortcut for router.Handle("PATCH", path, handlers).
 func (group *RouterGroup) PATCH(relativePath string, handlers ...HandlerFunc) IRoutes {
 	return group.handle(http.MethodPatch, relativePath, handlers)
 }
 
-// PUT is a shortcut for router.Handle("PUT", path, handle).
+// PUT is a shortcut for router.Handle("PUT", path, handlers).
 func (group *RouterGroup) PUT(relativePath string, handlers ...HandlerFunc) IRoutes {
 	return group.handle(http.MethodPut, relativePath, handlers)
 }
 
-// OPTIONS is a shortcut for router.Handle("OPTIONS", path, handle).
+// OPTIONS is a shortcut for router.Handle("OPTIONS", path, handlers).
 func (group *RouterGroup) OPTIONS(relativePath string, handlers ...HandlerFunc) IRoutes {
 	return group.handle(http.MethodOptions, relativePath, handlers)
 }
 
-// HEAD is a shortcut for router.Handle("HEAD", path, handle).
+// HEAD is a shortcut for router.Handle("HEAD", path, handlers).
 func (group *RouterGroup) HEAD(relativePath string, handlers ...HandlerFunc) IRoutes {
 	return group.handle(http.MethodHead, relativePath, handlers)
 }
@@ -161,7 +161,7 @@ func (group *RouterGroup) StaticFile(relativePath, filepath string) IRoutes {
 
 // StaticFileFS works just like `StaticFile` but a custom `http.FileSystem` can be used instead..
 // router.StaticFileFS("favicon.ico", "./resources/favicon.ico", Dir{".", false})
-// Gin by default user: gin.Dir()
+// Gin by default uses: gin.Dir()
 func (group *RouterGroup) StaticFileFS(relativePath, filepath string, fs http.FileSystem) IRoutes {
 	return group.staticFileHandler(relativePath, func(c *Context) {
 		c.FileFromFS(filepath, fs)
@@ -182,13 +182,14 @@ func (group *RouterGroup) staticFileHandler(relativePath string, handler Handler
 // of the Router's NotFound handler.
 // To use the operating system's file system implementation,
 // use :
-//     router.Static("/static", "/var/www")
+//
+//	router.Static("/static", "/var/www")
 func (group *RouterGroup) Static(relativePath, root string) IRoutes {
 	return group.StaticFS(relativePath, Dir(root, false))
 }
 
 // StaticFS works just like `Static()` but a custom `http.FileSystem` can be used instead.
-// Gin by default user: gin.Dir()
+// Gin by default uses: gin.Dir()
 func (group *RouterGroup) StaticFS(relativePath string, fs http.FileSystem) IRoutes {
 	if strings.Contains(relativePath, ":") || strings.Contains(relativePath, "*") {
 		panic("URL parameters can not be used when serving a static folder")
diff --git a/tree.go b/tree.go
index 956bf4d..3f34b8e 100644
--- a/tree.go
+++ b/tree.go
@@ -107,7 +107,8 @@ func countSections(path string) uint16 {
 type nodeType uint8
 
 const (
-	root nodeType = iota + 1
+	static nodeType = iota
+	root
 	param
 	catchAll
 )
@@ -173,6 +174,7 @@ walk:
 			child := node{
 				path:      n.path[i:],
 				wildChild: n.wildChild,
+				nType:     static,
 				indices:   n.indices,
 				children:  n.children,
 				handlers:  n.handlers,
@@ -604,6 +606,11 @@ walk: // Outer loop for walking the tree
 				return
 			}
 
+			if path == "/" && n.nType == static {
+				value.tsr = true
+				return
+			}
+
 			// No handle found. Check if a handle for this path + a
 			// trailing slash exists for trailing slash recommendation
 			for i, c := range []byte(n.indices) {


Test patch:
diff --git a/binding/binding_test.go b/binding/binding_test.go
index f099621..eae2780 100644
--- a/binding/binding_test.go
+++ b/binding/binding_test.go
@@ -1107,9 +1107,7 @@ func testFormBindingForType(t *testing.T, method, path, badPath, body, badBody s
 		assert.Equal(t,
 			struct {
 				Idx int "form:\"idx\""
-			}(struct {
-				Idx int "form:\"idx\""
-			}{Idx: 123}),
+			}{Idx: 123},
 			obj.StructFoo)
 	case "StructPointer":
 		obj := FooStructForStructPointerType{}
@@ -1118,9 +1116,7 @@ func testFormBindingForType(t *testing.T, method, path, badPath, body, badBody s
 		assert.Equal(t,
 			struct {
 				Name string "form:\"name\""
-			}(struct {
-				Name string "form:\"name\""
-			}{Name: "thinkerou"}),
+			}{Name: "thinkerou"},
 			*obj.StructPointerFoo)
 	case "Map":
 		obj := FooStructForMapType{}
diff --git a/binding/form_mapping_test.go b/binding/form_mapping_test.go
index 78f4df0..93d6a92 100644
--- a/binding/form_mapping_test.go
+++ b/binding/form_mapping_test.go
@@ -114,7 +114,7 @@ func TestMappingPrivateField(t *testing.T) {
 	}
 	err := mappingByPtr(&s, formSource{"field": {"6"}}, "form")
 	assert.NoError(t, err)
-	assert.Equal(t, int(0), s.f)
+	assert.Equal(t, 0, s.f)
 }
 
 func TestMappingUnknownFieldType(t *testing.T) {
@@ -133,7 +133,7 @@ func TestMappingURI(t *testing.T) {
 	}
 	err := mapURI(&s, map[string][]string{"field": {"6"}})
 	assert.NoError(t, err)
-	assert.Equal(t, int(6), s.F)
+	assert.Equal(t, 6, s.F)
 }
 
 func TestMappingForm(t *testing.T) {
@@ -142,7 +142,7 @@ func TestMappingForm(t *testing.T) {
 	}
 	err := mapForm(&s, map[string][]string{"field": {"6"}})
 	assert.NoError(t, err)
-	assert.Equal(t, int(6), s.F)
+	assert.Equal(t, 6, s.F)
 }
 
 func TestMapFormWithTag(t *testing.T) {
@@ -151,7 +151,7 @@ func TestMapFormWithTag(t *testing.T) {
 	}
 	err := MapFormWithTag(&s, map[string][]string{"field": {"6"}}, "externalTag")
 	assert.NoError(t, err)
-	assert.Equal(t, int(6), s.F)
+	assert.Equal(t, 6, s.F)
 }
 
 func TestMappingTime(t *testing.T) {
diff --git a/context_1.17_test.go b/context_1.17_test.go
index 69c9786..0f8527f 100644
--- a/context_1.17_test.go
+++ b/context_1.17_test.go
@@ -12,6 +12,8 @@ import (
 	"mime/multipart"
 	"net/http"
 	"net/http/httptest"
+	"runtime"
+	"strings"
 	"testing"
 
 	"github.com/stretchr/testify/assert"
@@ -28,9 +30,17 @@ func (i interceptedWriter) WriteHeader(code int) {
 }
 
 func TestContextFormFileFailed17(t *testing.T) {
+	if !isGo117OrGo118() {
+		return
+	}
 	buf := new(bytes.Buffer)
 	mw := multipart.NewWriter(buf)
-	mw.Close()
+	defer func(mw *multipart.Writer) {
+		err := mw.Close()
+		if err != nil {
+			assert.Error(t, err)
+		}
+	}(mw)
 	c, _ := CreateTestContext(httptest.NewRecorder())
 	c.Request, _ = http.NewRequest("POST", "/", nil)
 	c.Request.Header.Set("Content-Type", mw.FormDataContentType())
@@ -70,3 +80,15 @@ func TestInterceptedHeader(t *testing.T) {
 	assert.Equal(t, "", w.Result().Header.Get("X-Test"))
 	assert.Equal(t, "present", w.Result().Header.Get("X-Test-2"))
 }
+
+func isGo117OrGo118() bool {
+	version := strings.Split(runtime.Version()[2:], ".")
+	if len(version) >= 2 {
+		x := version[0]
+		y := version[1]
+		if x == "1" && (y == "17" || y == "18") {
+			return true
+		}
+	}
+	return false
+}
diff --git a/context_1.19_test.go b/context_1.19_test.go
new file mode 100644
index 0000000..4b34ea2
--- /dev/null
+++ b/context_1.19_test.go
@@ -0,0 +1,31 @@
+// Copyright 2022 Gin Core Team. All rights reserved.
+// Use of this source code is governed by a MIT style
+// license that can be found in the LICENSE file.
+
+//go:build go1.19
+// +build go1.19
+
+package gin
+
+import (
+	"bytes"
+	"mime/multipart"
+	"net/http"
+	"net/http/httptest"
+	"testing"
+
+	"github.com/stretchr/testify/assert"
+)
+
+func TestContextFormFileFailed19(t *testing.T) {
+	buf := new(bytes.Buffer)
+	mw := multipart.NewWriter(buf)
+	mw.Close()
+	c, _ := CreateTestContext(httptest.NewRecorder())
+	c.Request, _ = http.NewRequest("POST", "/", nil)
+	c.Request.Header.Set("Content-Type", mw.FormDataContentType())
+	c.engine.MaxMultipartMemory = 8 << 20
+	f, err := c.FormFile("file")
+	assert.Error(t, err)
+	assert.Nil(t, f)
+}
diff --git a/context_test.go b/context_test.go
index d09b0ae..85e0a61 100644
--- a/context_test.go
+++ b/context_test.go
@@ -30,7 +30,7 @@ import (
 	"google.golang.org/protobuf/proto"
 )
 
-var _ context.Context = &Context{}
+var _ context.Context = (*Context)(nil)
 
 // Unit tests TODO
 // func (c *Context) File(filepath string) {
@@ -146,13 +146,13 @@ func TestSaveUploadedCreateFailed(t *testing.T) {
 
 func TestContextReset(t *testing.T) {
 	router := New()
-	c := router.allocateContext()
+	c := router.allocateContext(0)
 	assert.Equal(t, c.engine, router)
 
 	c.index = 2
 	c.Writer = &responseWriter{ResponseWriter: httptest.NewRecorder()}
 	c.Params = Params{Param{}}
-	c.Error(errors.New("test")) // nolint: errcheck
+	c.Error(errors.New("test")) //nolint: errcheck
 	c.Set("foo", "bar")
 	c.reset()
 
@@ -1376,12 +1376,12 @@ func TestContextError(t *testing.T) {
 	assert.Empty(t, c.Errors)
 
 	firstErr := errors.New("first error")
-	c.Error(firstErr) // nolint: errcheck
+	c.Error(firstErr) //nolint: errcheck
 	assert.Len(t, c.Errors, 1)
 	assert.Equal(t, "Error #01: first error\n", c.Errors.String())
 
 	secondErr := errors.New("second error")
-	c.Error(&Error{ // nolint: errcheck
+	c.Error(&Error{ //nolint: errcheck
 		Err:  secondErr,
 		Meta: "some data 2",
 		Type: ErrorTypePublic,
@@ -1403,13 +1403,13 @@ func TestContextError(t *testing.T) {
 			t.Error("didn't panic")
 		}
 	}()
-	c.Error(nil) // nolint: errcheck
+	c.Error(nil) //nolint: errcheck
 }
 
 func TestContextTypedError(t *testing.T) {
 	c, _ := CreateTestContext(httptest.NewRecorder())
-	c.Error(errors.New("externo 0")).SetType(ErrorTypePublic)  // nolint: errcheck
-	c.Error(errors.New("interno 0")).SetType(ErrorTypePrivate) // nolint: errcheck
+	c.Error(errors.New("externo 0")).SetType(ErrorTypePublic)  //nolint: errcheck
+	c.Error(errors.New("interno 0")).SetType(ErrorTypePrivate) //nolint: errcheck
 
 	for _, err := range c.Errors.ByType(ErrorTypePublic) {
 		assert.Equal(t, ErrorTypePublic, err.Type)
@@ -1424,7 +1424,7 @@ func TestContextAbortWithError(t *testing.T) {
 	w := httptest.NewRecorder()
 	c, _ := CreateTestContext(w)
 
-	c.AbortWithError(http.StatusUnauthorized, errors.New("bad input")).SetMeta("some input") // nolint: errcheck
+	c.AbortWithError(http.StatusUnauthorized, errors.New("bad input")).SetMeta("some input") //nolint: errcheck
 
 	assert.Equal(t, http.StatusUnauthorized, w.Code)
 	assert.Equal(t, abortIndex, c.index)
@@ -2354,3 +2354,17 @@ func TestContextAddParam(t *testing.T) {
 	assert.Equal(t, ok, true)
 	assert.Equal(t, value, v)
 }
+
+func TestCreateTestContextWithRouteParams(t *testing.T) {
+	w := httptest.NewRecorder()
+	engine := New()
+	engine.GET("/:action/:name", func(ctx *Context) {
+		ctx.String(http.StatusOK, "%s %s", ctx.Param("action"), ctx.Param("name"))
+	})
+	c := CreateTestContextOnly(w, engine)
+	c.Request, _ = http.NewRequest(http.MethodGet, "/hello/gin", nil)
+	engine.HandleContext(c)
+
+	assert.Equal(t, http.StatusOK, w.Code)
+	assert.Equal(t, "hello gin", w.Body.String())
+}
diff --git a/debug_test.go b/debug_test.go
index bf0e6ab..abe8b41 100644
--- a/debug_test.go
+++ b/debug_test.go
@@ -104,7 +104,7 @@ func TestDebugPrintWARNINGDefault(t *testing.T) {
 	})
 	m, e := getMinVer(runtime.Version())
 	if e == nil && m < ginSupportMinGoVer {
-		assert.Equal(t, "[GIN-debug] [WARNING] Now Gin requires Go 1.15+.\n\n[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.\n\n", re)
+		assert.Equal(t, "[GIN-debug] [WARNING] Now Gin requires Go 1.16+.\n\n[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.\n\n", re)
 	} else {
 		assert.Equal(t, "[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.\n\n", re)
 	}
diff --git a/errors_test.go b/errors_test.go
index 78d561c..f77a634 100644
--- a/errors_test.go
+++ b/errors_test.go
@@ -35,7 +35,7 @@ func TestError(t *testing.T) {
 	jsonBytes, _ := json.Marshal(err)
 	assert.Equal(t, "{\"error\":\"test error\",\"meta\":\"some data\"}", string(jsonBytes))
 
-	err.SetMeta(H{ // nolint: errcheck
+	err.SetMeta(H{ //nolint: errcheck
 		"status": "200",
 		"data":   "some data",
 	})
@@ -45,7 +45,7 @@ func TestError(t *testing.T) {
 		"data":   "some data",
 	}, err.JSON())
 
-	err.SetMeta(H{ // nolint: errcheck
+	err.SetMeta(H{ //nolint: errcheck
 		"error":  "custom error",
 		"status": "200",
 		"data":   "some data",
@@ -60,7 +60,7 @@ func TestError(t *testing.T) {
 		status string
 		data   string
 	}
-	err.SetMeta(customError{status: "200", data: "other data"}) // nolint: errcheck
+	err.SetMeta(customError{status: "200", data: "other data"}) //nolint: errcheck
 	assert.Equal(t, customError{status: "200", data: "other data"}, err.JSON())
 }
 
diff --git a/gin_test.go b/gin_test.go
index 02f2324..4fac677 100644
--- a/gin_test.go
+++ b/gin_test.go
@@ -100,7 +100,7 @@ func TestH2c(t *testing.T) {
 
 	url := "http://" + ln.Addr().String() + "/"
 
-	http := http.Client{
+	httpClient := http.Client{
 		Transport: &http2.Transport{
 			AllowHTTP: true,
 			DialTLS: func(netw, addr string, cfg *tls.Config) (net.Conn, error) {
@@ -109,7 +109,7 @@ func TestH2c(t *testing.T) {
 		},
 	}
 
-	res, err := http.Get(url)
+	res, err := httpClient.Get(url)
 	if err != nil {
 		fmt.Println(err)
 	}
diff --git a/logger_test.go b/logger_test.go
index fa0d9ce..7bc1137 100644
--- a/logger_test.go
+++ b/logger_test.go
@@ -358,13 +358,13 @@ func TestErrorLogger(t *testing.T) {
 	router := New()
 	router.Use(ErrorLogger())
 	router.GET("/error", func(c *Context) {
-		c.Error(errors.New("this is an error")) // nolint: errcheck
+		c.Error(errors.New("this is an error")) //nolint: errcheck
 	})
 	router.GET("/abort", func(c *Context) {
-		c.AbortWithError(http.StatusUnauthorized, errors.New("no authorized")) // nolint: errcheck
+		c.AbortWithError(http.StatusUnauthorized, errors.New("no authorized")) //nolint: errcheck
 	})
 	router.GET("/print", func(c *Context) {
-		c.Error(errors.New("this is an error")) // nolint: errcheck
+		c.Error(errors.New("this is an error")) //nolint: errcheck
 		c.String(http.StatusInternalServerError, "hola!")
 	})
 
diff --git a/middleware_test.go b/middleware_test.go
index a235fe9..acdf89c 100644
--- a/middleware_test.go
+++ b/middleware_test.go
@@ -211,7 +211,7 @@ func TestMiddlewareFailHandlersChain(t *testing.T) {
 	router := New()
 	router.Use(func(context *Context) {
 		signature += "A"
-		context.AbortWithError(http.StatusInternalServerError, errors.New("foo")) // nolint: errcheck
+		context.AbortWithError(http.StatusInternalServerError, errors.New("foo")) //nolint: errcheck
 	})
 	router.Use(func(context *Context) {
 		signature += "B"
diff --git a/render/render_test.go b/render/render_test.go
index a13fff4..3509db3 100644
--- a/render/render_test.go
+++ b/render/render_test.go
@@ -173,7 +173,7 @@ func TestRenderAsciiJSON(t *testing.T) {
 	assert.Equal(t, "application/json", w1.Header().Get("Content-Type"))
 
 	w2 := httptest.NewRecorder()
-	data2 := float64(3.1415926)
+	data2 := 3.1415926
 
 	err = (AsciiJSON{data2}).Render(w2)
 	assert.NoError(t, err)
diff --git a/test_helpers.go b/test_helpers.go
index b3be93b..7508c5c 100644
--- a/test_helpers.go
+++ b/test_helpers.go
@@ -9,7 +9,15 @@ import "net/http"
 // CreateTestContext returns a fresh engine and context for testing purposes
 func CreateTestContext(w http.ResponseWriter) (c *Context, r *Engine) {
 	r = New()
-	c = r.allocateContext()
+	c = r.allocateContext(0)
+	c.reset()
+	c.writermem.reset(w)
+	return
+}
+
+// CreateTestContextOnly returns a fresh context base on the engine for testing purposes
+func CreateTestContextOnly(w http.ResponseWriter, r *Engine) (c *Context) {
+	c = r.allocateContext(r.maxParams)
 	c.reset()
 	c.writermem.reset(w)
 	return
diff --git a/tree_test.go b/tree_test.go
index 085b580..2005738 100644
--- a/tree_test.go
+++ b/tree_test.go
@@ -684,6 +684,26 @@ func TestTreeRootTrailingSlashRedirect(t *testing.T) {
 	}
 }
 
+func TestRedirectTrailingSlash(t *testing.T) {
+	var data = []struct {
+		path string
+	}{
+		{"/hello/:name"},
+		{"/hello/:name/123"},
+		{"/hello/:name/234"},
+	}
+
+	node := &node{}
+	for _, item := range data {
+		node.addRoute(item.path, fakeHandler("test"))
+	}
+
+	value := node.getValue("/hello/abx/", nil, getSkippedNodes(), false)
+	if value.tsr != true {
+		t.Fatalf("want true, is false")
+	}
+}
+
 func TestTreeFindCaseInsensitivePath(t *testing.T) {
 	tree := &node{}