Skip to content

Commit ac4ce21

Browse files
🐛 Bug: Fix issues introduced in linting PR (gofiber#2319)
* internal: revert linting changes Changes to the internal package should not have been made in 167a8b5. * middleware/monitor: revert changes to exported field "ChartJSURL" This is a breaking change introduced in 167a8b5. * middleware/monitor: fix error checking Fix the errorenous error checking introduced in 167a8b5. * 🐛 Bug: Fix issues introduced in linting PR gofiber#2319 * 🐛 Bug: Fix issues introduced in linting PR gofiber#2319 * Bug: Fix issues introduced in linting PR gofiber#2319 --------- Co-authored-by: René Werner <[email protected]>
1 parent 44d0920 commit ac4ce21

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+98
-9594
lines changed

.golangci.yml

+1-66
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,12 @@ run:
55
modules-download-mode: readonly
66
skip-dirs-use-default: false
77
skip-dirs:
8-
- internal # TODO: Also apply proper linting for internal dir
8+
- internal
99

1010
output:
1111
sort-results: true
1212

1313
linters-settings:
14-
# TODO: Eventually enable these checks
15-
# depguard:
16-
# include-go-root: true
17-
# packages:
18-
# - flag
19-
# - io/ioutil
20-
# - reflect
21-
# - unsafe
22-
# packages-with-error-message:
23-
# - flag: '`flag` package is only allowed in main.go'
24-
# - io/ioutil: '`io/ioutil` package is deprecated, use the `io` and `os` package instead'
25-
# - reflect: '`reflect` package is dangerous to use'
26-
# - unsafe: '`unsafe` package is dangerous to use'
27-
2814
errcheck:
2915
check-type-assertions: true
3016
check-blank: true
@@ -44,15 +30,6 @@ linters-settings:
4430
# - 'time\.Sleep'
4531
# - 'panic'
4632

47-
gci:
48-
sections:
49-
- standard
50-
- prefix(github.com/gofiber/fiber)
51-
- default
52-
- blank
53-
- dot
54-
custom-order: true
55-
5633
gocritic:
5734
disabled-checks:
5835
- ifElseChain
@@ -162,86 +139,47 @@ linters:
162139
- bodyclose
163140
- containedctx
164141
- contextcheck
165-
# - cyclop
166-
# - deadcode
167-
# - decorder
168142
- depguard
169143
- dogsled
170-
# - dupl
171-
# - dupword
172144
- durationcheck
173145
- errcheck
174146
- errchkjson
175147
- errname
176148
- errorlint
177149
- execinquery
178150
- exhaustive
179-
# - exhaustivestruct
180-
# - exhaustruct
181151
- exportloopref
182152
- forbidigo
183153
- forcetypeassert
184-
# - funlen
185-
- gci
186-
- gochecknoglobals
187-
- gochecknoinits
188-
# - gocognit
189154
- goconst
190155
- gocritic
191-
# - gocyclo
192-
# - godot
193-
# - godox
194-
# - goerr113
195156
- gofmt
196157
- gofumpt
197-
# - goheader
198158
- goimports
199-
# - golint
200-
- gomnd
201159
- gomoddirectives
202-
# - gomodguard
203160
- goprintffuncname
204161
- gosec
205162
- gosimple
206163
- govet
207164
- grouper
208-
# - ifshort
209-
# - importas
210-
- ineffassign
211-
# - interfacebloat
212-
# - interfacer
213-
# - ireturn
214-
# - lll
215165
- loggercheck
216-
# - maintidx
217-
# - makezero
218-
# - maligned
219166
- misspell
220167
- nakedret
221-
# - nestif
222168
- nilerr
223169
- nilnil
224-
# - nlreturn
225170
- noctx
226171
- nolintlint
227172
- nonamedreturns
228-
# - nosnakecase
229173
- nosprintfhostport
230-
# - paralleltest # TODO: Enable once https://github.com/gofiber/fiber/issues/2254 is implemented
231-
# - prealloc
232174
- predeclared
233175
- promlinter
234176
- reassign
235177
- revive
236178
- rowserrcheck
237-
# - scopelint
238179
- sqlclosecheck
239180
- staticcheck
240-
# - structcheck
241181
- stylecheck
242182
- tagliatelle
243-
# - tenv # TODO: Enable once we drop support for Go 1.16
244-
# - testableexamples
245183
# - testpackage # TODO: Enable once https://github.com/gofiber/fiber/issues/2252 is implemented
246184
- thelper
247185
# - tparallel # TODO: Enable once https://github.com/gofiber/fiber/issues/2254 is implemented
@@ -250,9 +188,6 @@ linters:
250188
- unparam
251189
- unused
252190
- usestdlibvars
253-
# - varcheck
254-
# - varnamelen
255191
- wastedassign
256192
- whitespace
257193
- wrapcheck
258-
# - wsl

app.go

-2
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,6 @@ const (
456456
)
457457

458458
// HTTP methods enabled by default
459-
//
460-
//nolint:gochecknoglobals // Using a global var is fine here
461459
var DefaultMethods = []string{
462460
MethodGet,
463461
MethodHead,

client.go

-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ type Args = fasthttp.Args
5151
// Copy from fasthttp
5252
type RetryIfFunc = fasthttp.RetryIfFunc
5353

54-
//nolint:gochecknoglobals // TODO: Do not use a global var here
5554
var defaultClient Client
5655

5756
// Client implements http client.
@@ -859,7 +858,6 @@ func (a *Agent) reset() {
859858
a.formFiles = a.formFiles[:0]
860859
}
861860

862-
//nolint:gochecknoglobals // TODO: Do not use global vars here
863861
var (
864862
clientPool sync.Pool
865863
agentPool = sync.Pool{

color.go

-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ type Colors struct {
5353
}
5454

5555
// DefaultColors Default color codes
56-
//
57-
//nolint:gochecknoglobals // Using a global var is fine here
5856
var DefaultColors = Colors{
5957
Black: "\u001b[90m",
6058
Red: "\u001b[91m",

ctx.go

+3-6
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ import (
2424
"text/template"
2525
"time"
2626

27-
"github.com/gofiber/fiber/v2/internal/dictpool"
2827
"github.com/gofiber/fiber/v2/internal/schema"
2928
"github.com/gofiber/fiber/v2/utils"
3029

30+
"github.com/savsgio/dictpool"
3131
"github.com/valyala/bytebufferpool"
3232
"github.com/valyala/fasthttp"
3333
)
@@ -51,15 +51,13 @@ const (
5151
// userContextKey define the key name for storing context.Context in *fasthttp.RequestCtx
5252
const userContextKey = "__local_user_context__"
5353

54-
//nolint:gochecknoglobals // TODO: Do not use global vars here
5554
var (
5655
// decoderPoolMap helps to improve BodyParser's, QueryParser's and ReqHeaderParser's performance
5756
decoderPoolMap = map[string]*sync.Pool{}
5857
// tags is used to classify parser's pool
5958
tags = []string{queryTag, bodyTag, reqHeaderTag, paramsTag}
6059
)
6160

62-
//nolint:gochecknoinits // init() is used to initialize a global map variable
6361
func init() {
6462
for _, tag := range tags {
6563
decoderPoolMap[tag] = &sync.Pool{New: func() interface{} {
@@ -730,7 +728,7 @@ iploop:
730728
var v4, v6 bool
731729

732730
// Manually splitting string without allocating slice, working with parts directly
733-
i, j = j+1, j+2 //nolint:gomnd // Using these values is fine
731+
i, j = j+1, j+2
734732

735733
if j > len(headerValue) {
736734
break
@@ -780,7 +778,7 @@ func (c *Ctx) extractIPFromHeader(header string) string {
780778
var v4, v6 bool
781779

782780
// Manually splitting string without allocating slice, working with parts directly
783-
i, j = j+1, j+2 //nolint:gomnd // Using these values is fine
781+
i, j = j+1, j+2
784782

785783
if j > len(headerValue) {
786784
break
@@ -1559,7 +1557,6 @@ func (c *Ctx) Send(body []byte) error {
15591557
return nil
15601558
}
15611559

1562-
//nolint:gochecknoglobals // TODO: Do not use global vars here
15631560
var (
15641561
sendFileOnce sync.Once
15651562
sendFileFS *fasthttp.FS

go.mod

+5
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ module github.com/gofiber/fiber/v2
33
go 1.19
44

55
require (
6+
github.com/google/uuid v1.3.0
67
github.com/mattn/go-colorable v0.1.13
78
github.com/mattn/go-isatty v0.0.17
89
github.com/mattn/go-runewidth v0.0.14
10+
github.com/savsgio/dictpool v0.0.0-20221023140959-7bf2e61cea94
11+
github.com/tinylib/msgp v1.1.6
912
github.com/valyala/bytebufferpool v1.0.0
1013
github.com/valyala/fasthttp v1.44.0
1114
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab
@@ -14,6 +17,8 @@ require (
1417
require (
1518
github.com/andybalholm/brotli v1.0.4 // indirect
1619
github.com/klauspost/compress v1.15.9 // indirect
20+
github.com/philhofer/fwd v1.1.1 // indirect
1721
github.com/rivo/uniseg v0.2.0 // indirect
22+
github.com/savsgio/gotils v0.0.0-20220530130905-52f3993e8d6d // indirect
1823
github.com/valyala/tcplisten v1.0.0 // indirect
1924
)

go.sum

+30
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY=
22
github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
3+
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
4+
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
35
github.com/klauspost/compress v1.15.9 h1:wKRjX6JRtDdrE9qwa4b/Cip7ACOshUI4smpCQanqjSY=
46
github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU=
57
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
@@ -9,17 +11,38 @@ github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPn
911
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
1012
github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU=
1113
github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
14+
github.com/philhofer/fwd v1.1.1 h1:GdGcTjf5RNAxwS4QLsiMzJYj5KEvPJD3Abr261yRQXQ=
15+
github.com/philhofer/fwd v1.1.1/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU=
1216
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
1317
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
18+
github.com/savsgio/dictpool v0.0.0-20221023140959-7bf2e61cea94 h1:rmMl4fXJhKMNWl+K+r/fq4FbbKI+Ia2m9hYBLm2h4G4=
19+
github.com/savsgio/dictpool v0.0.0-20221023140959-7bf2e61cea94/go.mod h1:90zrgN3D/WJsDd1iXHT96alCoN2KJo6/4x1DZC3wZs8=
20+
github.com/savsgio/gotils v0.0.0-20220530130905-52f3993e8d6d h1:Q+gqLBOPkFGHyCJxXMRqtUgUbTjI8/Ze8vu8GGyNFwo=
21+
github.com/savsgio/gotils v0.0.0-20220530130905-52f3993e8d6d/go.mod h1:Gy+0tqhJvgGlqnTF8CVGP0AaGRjwBtXs/a5PA0Y3+A4=
22+
github.com/tinylib/msgp v1.1.6 h1:i+SbKraHhnrf9M5MYmvQhFnbLhAXSDWF8WWsuyRdocw=
23+
github.com/tinylib/msgp v1.1.6/go.mod h1:75BAfg2hauQhs3qedfdDZmWAPcFMAvJE5b9rGOMufyw=
1424
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
1525
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
1626
github.com/valyala/fasthttp v1.44.0 h1:R+gLUhldIsfg1HokMuQjdQ5bh9nuXHPIfvkYUu9eR5Q=
1727
github.com/valyala/fasthttp v1.44.0/go.mod h1:f6VbjjoI3z1NDOZOv17o6RvtRSWxC77seBFc2uWtgiY=
1828
github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8=
1929
github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc=
30+
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
31+
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
32+
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
33+
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
2034
golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
35+
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
36+
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
37+
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
38+
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
2139
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
2240
golang.org/x/net v0.0.0-20220906165146-f3363e06e74c/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
41+
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
42+
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
43+
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
44+
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
45+
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
2346
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
2447
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
2548
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@@ -28,6 +51,13 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab h1:2QkjZIsXupsJbJIdSjjUOgWK3
2851
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
2952
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
3053
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
54+
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
55+
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
3156
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
3257
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
3358
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
59+
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
60+
golang.org/x/tools v0.0.0-20201022035929-9cf592e881e9/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
61+
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
62+
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
63+
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

helpers.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -266,12 +266,12 @@ func (app *App) isEtagStale(etag string, noneMatchBytes []byte) bool {
266266
// https://github.com/jshttp/fresh/blob/10e0471669dbbfbfd8de65bc6efac2ddd0bfa057/index.js#L110
267267
for i := range noneMatchBytes {
268268
switch noneMatchBytes[i] {
269-
case 0x20: //nolint:gomnd // This is a space (" ")
269+
case 0x20:
270270
if start == end {
271271
start = i + 1
272272
end = i + 1
273273
}
274-
case 0x2c: //nolint:gomnd // This is a comma (",")
274+
case 0x2c:
275275
if matchEtag(app.getString(noneMatchBytes[start:end]), etag) {
276276
return false
277277
}
@@ -347,7 +347,7 @@ func getBytesImmutable(s string) []byte {
347347
func (app *App) methodInt(s string) int {
348348
// For better performance
349349
if len(app.configured.RequestMethods) == 0 {
350-
//nolint:gomnd // TODO: Use iota instead
350+
// TODO: Use iota instead
351351
switch s {
352352
case MethodGet:
353353
return 0

0 commit comments

Comments
 (0)