Skip to content

Commit fcea5e9

Browse files
committed
chore: fix lint
Signed-off-by: Bo-Yi Wu <[email protected]>
1 parent 0d401cc commit fcea5e9

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

example/main.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"log"
45
"net/http"
56

67
limits "github.com/gin-contrib/size"
@@ -16,8 +17,10 @@ func handler(ctx *gin.Context) {
1617
}
1718

1819
func main() {
19-
rtr := gin.Default()
20-
rtr.Use(limits.RequestSizeLimiter(10))
21-
rtr.POST("/", handler)
22-
rtr.Run(":8080")
20+
r := gin.Default()
21+
r.Use(limits.RequestSizeLimiter(10))
22+
r.POST("/", handler)
23+
if err := r.Run(":8080"); err != nil {
24+
log.Fatal(err)
25+
}
2326
}

size.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func (mbr *maxBytesReader) tooLarge() (n int, err error) {
2222
if !mbr.wasAborted {
2323
mbr.wasAborted = true
2424
ctx := mbr.ctx
25-
ctx.Error(err)
25+
_ = ctx.Error(err)
2626
ctx.Header("connection", "close")
2727
ctx.String(http.StatusRequestEntityTooLarge, "request too large")
2828
ctx.AbortWithStatus(http.StatusRequestEntityTooLarge)

size_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func TestRequestSizeLimiterOK(t *testing.T) {
1414
router := gin.New()
1515
router.Use(RequestSizeLimiter(10))
1616
router.POST("/test_ok", func(c *gin.Context) {
17-
ioutil.ReadAll(c.Request.Body)
17+
_, _ = ioutil.ReadAll(c.Request.Body)
1818
if len(c.Errors) > 0 {
1919
return
2020
}
@@ -32,7 +32,7 @@ func TestRequestSizeLimiterOver(t *testing.T) {
3232
router := gin.New()
3333
router.Use(RequestSizeLimiter(10))
3434
router.POST("/test_large", func(c *gin.Context) {
35-
ioutil.ReadAll(c.Request.Body)
35+
_, _ = ioutil.ReadAll(c.Request.Body)
3636
if len(c.Errors) > 0 {
3737
return
3838
}

0 commit comments

Comments
 (0)