Skip to content

Commit cac80fa

Browse files
authoredMar 28, 2025··
Update to golangci-lint 2 (#18050)
Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
1 parent adee0bc commit cac80fa

File tree

116 files changed

+574
-604
lines changed

Some content is hidden

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

116 files changed

+574
-604
lines changed
 

‎.github/workflows/static_checks_etc.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ jobs:
197197
198198
- name: Install golangci-lint
199199
if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.go_files == 'true'
200-
run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.5
200+
run: go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.0.2
201201

202202
- name: Clean Env
203203
if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.go_files == 'true'

‎.golangci.yml

+189-184
Original file line numberDiff line numberDiff line change
@@ -1,194 +1,199 @@
1+
version: "2"
12
run:
2-
go: 1.24
3-
timeout: 10m
4-
5-
linters-settings:
6-
depguard:
7-
rules:
8-
use_modern_packages:
9-
list-mode: lax
10-
deny:
11-
- pkg: "math/rand$"
12-
desc: Please use math/rand/v2
13-
errcheck:
14-
exclude-functions:
15-
- flag.Set
16-
- (*flag.FlagSet).Parse
17-
- (flag.Value).Set
18-
- fmt.Fprint
19-
- fmt.Fprintf
20-
- io.WriteString(fmt.State)
21-
- io.WriteString(net/http.ResponseWriter)
22-
- (net.Listener).Close
23-
- (net/http.ResponseWriter).Write
24-
- (*os.File).Close
25-
- os.Remove
26-
- os.RemoveAll
27-
- os.Rename
28-
- (*github.com/spf13/cobra.Command).Help
29-
- (*github.com/spf13/cobra.Command).MarkFlagRequired
30-
- (*github.com/spf13/cobra.Command).MarkPersistentFlagRequired
31-
- (*github.com/spf13/cobra.Command).MarkPersistentFlagFilename
32-
- (*github.com/spf13/pflag.FlagSet).MarkDeprecated
33-
- (*google.golang.org/grpc.ClientConn).Close
34-
- (*google.golang.org/grpc.Server).Serve
35-
- (*vitess.io/vitess/go/bytes2.Buffer).Write
36-
- (*vitess.io/vitess/go/bytes2.Buffer).WriteByte
37-
- (*vitess.io/vitess/go/bytes2.Buffer).WriteString
38-
- (vitess.io/vitess/go/sqltypes.BinWriter).Write
39-
- vitess.io/vitess/go/vt/orchestrator/external/golib/log.Errore
40-
- vitess.io/vitess/go/vt/orchestrator/external/golib/log.Errorf
41-
- vitess.io/vitess/go/vt/orchestrator/external/golib/log.Fatal
42-
- vitess.io/vitess/go/vt/orchestrator/external/golib/log.Fatale
43-
- vitess.io/vitess/go/vt/orchestrator/external/golib/log.Fatalf
44-
- (*vitess.io/vitess/go/vt/vttest.LocalCluster).TearDown
45-
46-
goimports:
47-
local-prefixes: vitess.io/vitess
48-
govet:
49-
disable: # not supported when using Generics in 1.18
50-
- nilness
51-
- unusedwrite
52-
- loopclosure # fixed in go1.22
53-
3+
go: "1.24"
544
linters:
55-
disable-all: true
5+
default: none
566
enable:
57-
# Defaults
7+
- bodyclose
588
- depguard
599
- errcheck
6010
- govet
6111
- ineffassign
62-
- typecheck
6312
- staticcheck
64-
- gosimple
65-
66-
# Extras
13+
settings:
14+
depguard:
15+
rules:
16+
use_modern_packages:
17+
list-mode: lax
18+
deny:
19+
- pkg: math/rand$
20+
desc: Please use math/rand/v2
21+
errcheck:
22+
exclude-functions:
23+
- flag.Set
24+
- (*flag.FlagSet).Parse
25+
- (flag.Value).Set
26+
- fmt.Fprint
27+
- fmt.Fprintf
28+
- io.WriteString(fmt.State)
29+
- io.WriteString(net/http.ResponseWriter)
30+
- (net.Listener).Close
31+
- (net/http.ResponseWriter).Write
32+
- (*os.File).Close
33+
- os.Remove
34+
- os.RemoveAll
35+
- os.Rename
36+
- (*github.com/spf13/cobra.Command).Help
37+
- (*github.com/spf13/cobra.Command).MarkFlagRequired
38+
- (*github.com/spf13/cobra.Command).MarkPersistentFlagRequired
39+
- (*github.com/spf13/cobra.Command).MarkPersistentFlagFilename
40+
- (*github.com/spf13/pflag.FlagSet).MarkDeprecated
41+
- (*google.golang.org/grpc.ClientConn).Close
42+
- (*google.golang.org/grpc.Server).Serve
43+
- (*vitess.io/vitess/go/bytes2.Buffer).Write
44+
- (*vitess.io/vitess/go/bytes2.Buffer).WriteByte
45+
- (*vitess.io/vitess/go/bytes2.Buffer).WriteString
46+
- (vitess.io/vitess/go/sqltypes.BinWriter).Write
47+
- vitess.io/vitess/go/vt/orchestrator/external/golib/log.Errore
48+
- vitess.io/vitess/go/vt/orchestrator/external/golib/log.Errorf
49+
- vitess.io/vitess/go/vt/orchestrator/external/golib/log.Fatal
50+
- vitess.io/vitess/go/vt/orchestrator/external/golib/log.Fatale
51+
- vitess.io/vitess/go/vt/orchestrator/external/golib/log.Fatalf
52+
- (*vitess.io/vitess/go/vt/vttest.LocalCluster).TearDown
53+
govet:
54+
disable:
55+
- nilness
56+
- unusedwrite
57+
- loopclosure
58+
staticcheck:
59+
checks:
60+
- "all"
61+
- "-ST1000"
62+
- "-ST1003"
63+
- "-ST1005"
64+
- "-ST1016"
65+
- "-ST1020"
66+
- "-ST1021"
67+
- "-ST1022"
68+
- "-QF1001"
69+
- "-QF1005"
70+
- "-QF1008"
71+
exclusions:
72+
generated: lax
73+
presets:
74+
- comments
75+
- common-false-positives
76+
- legacy
77+
- std-error-handling
78+
rules:
79+
- linters:
80+
- errcheck
81+
path: ^go/vt/proto/
82+
- linters:
83+
- errcheck
84+
path: ^go/cmd/(vtcombo|vtgateclienttest|vtorc)/
85+
- linters:
86+
- errcheck
87+
path: ^go/mysql/
88+
- linters:
89+
- revive
90+
path: ^go/mysql/collations
91+
- linters:
92+
- errcheck
93+
path: ^go/pools/.*_test.go
94+
- linters:
95+
- errcheck
96+
path: ^go/sqltypes/
97+
- linters:
98+
- errcheck
99+
path: ^go/stats/statsd/
100+
- linters:
101+
- errcheck
102+
path: ^go/test/
103+
- linters:
104+
- errcheck
105+
path: ^go/vt/automation/
106+
- linters:
107+
- errcheck
108+
path: ^go/vt/mysqlctl/
109+
- linters:
110+
- errcheck
111+
path: ^go/vt/orchestrator/
112+
- linters:
113+
- errcheck
114+
path: ^go/vt/orchestrator/external/
115+
- linters:
116+
- errcheck
117+
path: ^go/vt/schemamanager/
118+
- linters:
119+
- errcheck
120+
path: ^go/vt/servenv/
121+
- linters:
122+
- errcheck
123+
path: ^go/vt/sqlparser/(ast_format|ast_format_fast).go
124+
- linters:
125+
- errcheck
126+
path: ^go/vt/sqlparser/goyacc
127+
- linters:
128+
- errcheck
129+
path: ^go/vt/throttler/.*_test.go
130+
- linters:
131+
- errcheck
132+
path: ^go/vt/topo/.*/*._test.go
133+
- linters:
134+
- errcheck
135+
path: ^go/vt/vtcombo/
136+
- linters:
137+
- errcheck
138+
path: ^go/vt/vtctl/[^/]*.go
139+
- linters:
140+
- errcheck
141+
path: ^go/vt/vtctl/grpcvtctlclient/
142+
- linters:
143+
- errcheck
144+
path: ^go/vt/vtctl/grpcvtctlserver/
145+
- linters:
146+
- errcheck
147+
path: ^go/vt/vtctld/(schema|.*_test).go
148+
- linters:
149+
- errcheck
150+
path: ^go/vt/vtexplain/
151+
- linters:
152+
- errcheck
153+
path: ^go/vt/vtgate/.*_test.go
154+
- linters:
155+
- errcheck
156+
path: ^go/vt/vtgr/
157+
- linters:
158+
- errcheck
159+
path: ^go/vt/vttablet/(customrule|filelogger|grpctmserver|onlineddl|sandboxconn|tabletserver)/
160+
- linters:
161+
- errcheck
162+
path: ^go/vt/vttablet/tabletmanager/vreplication
163+
- linters:
164+
- errcheck
165+
path: ^go/vt/vttablet/(.*endtoend.*|.*_test.go)
166+
- linters:
167+
- errcheck
168+
path: ^go/vt/vttest
169+
- linters:
170+
- errcheck
171+
path: ^go/vt/worker
172+
- linters:
173+
- errcheck
174+
path: ^go/vt/workflow
175+
- linters:
176+
- errcheck
177+
path: ^go/vt/wrangler
178+
- linters:
179+
- errcheck
180+
path: ^go/vt/zkctl
181+
paths:
182+
- third_party$
183+
- builtin$
184+
- examples$
185+
formatters:
186+
enable:
67187
- gofmt
68188
- goimports
69-
- bodyclose
70-
71-
# revive is a replacement for golint, but we do not run it in CI for now.
72-
# This is only enabled as a post-commit hook
73-
# - revive
74-
75-
issues:
76-
exclude-rules:
77-
- path: '^go/vt/proto/'
78-
linters:
79-
- errcheck
80-
- goimports
81-
82-
### BEGIN: errcheck exclusion rules. Each rule should be considered
83-
# a TODO for removal after adding error checks to that package/file/etc,
84-
# except where otherwise noted.
85-
- path: '^go/cmd/(vtcombo|vtgateclienttest|vtorc)/'
86-
linters:
87-
- errcheck
88-
- path: '^go/mysql/'
89-
linters:
90-
- errcheck
91-
- path: '^go/mysql/collations'
92-
linters:
93-
- revive
94-
- path: '^go/pools/.*_test.go'
95-
linters:
96-
- errcheck
97-
- path: '^go/sqltypes/'
98-
linters:
99-
- errcheck
100-
- path: '^go/stats/statsd/'
101-
linters:
102-
- errcheck
103-
- path: '^go/test/'
104-
linters:
105-
- errcheck
106-
- path: '^go/vt/automation/'
107-
linters:
108-
- errcheck
109-
- path: '^go/vt/mysqlctl/'
110-
linters:
111-
- errcheck
112-
# (NB: @ajm188) Technically, the below `exclude-rules` for `go/vt/orchestrator/external` is
113-
# redundant with this line, but we actually want to permanently ignore orchestrator's
114-
# vendored code, so we are keeping the exclusion rules separate because this one
115-
# should be temporary while the latter should be permanent.
116-
- path: '^go/vt/orchestrator/'
117-
linters:
118-
- errcheck
119-
# This subtree should be permanently excluded, as it's vendored code.
120-
- path: '^go/vt/orchestrator/external/'
121-
linters:
122-
- errcheck
123-
- path: '^go/vt/schemamanager/'
124-
linters:
125-
- errcheck
126-
- path: '^go/vt/servenv/'
127-
linters:
128-
- errcheck
129-
# This code is autogenerated and should be permanently excluded.
130-
- path: '^go/vt/sqlparser/(ast_format|ast_format_fast).go'
131-
linters:
132-
- errcheck
133-
- path: '^go/vt/sqlparser/goyacc'
134-
linters:
135-
- errcheck
136-
- path: '^go/vt/throttler/.*_test.go'
137-
linters:
138-
- errcheck
139-
- path: '^go/vt/topo/.*/*._test.go'
140-
linters:
141-
- errcheck
142-
- path: '^go/vt/vtcombo/'
143-
linters:
144-
- errcheck
145-
- path: '^go/vt/vtctl/[^/]*.go'
146-
linters:
147-
- errcheck
148-
- path: '^go/vt/vtctl/grpcvtctlclient/'
149-
linters:
150-
- errcheck
151-
- path: '^go/vt/vtctl/grpcvtctlserver/'
152-
linters:
153-
- errcheck
154-
- path: '^go/vt/vtctld/(schema|.*_test).go'
155-
linters:
156-
- errcheck
157-
- path: '^go/vt/vtexplain/'
158-
linters:
159-
- errcheck
160-
- path: '^go/vt/vtgate/.*_test.go'
161-
linters:
162-
- errcheck
163-
- path: '^go/vt/vtgr/'
164-
linters:
165-
- errcheck
166-
- path: '^go/vt/vttablet/(customrule|filelogger|grpctmserver|onlineddl|sandboxconn|tabletserver)/'
167-
linters:
168-
- errcheck
169-
- path: '^go/vt/vttablet/tabletmanager/vreplication'
170-
linters:
171-
- errcheck
172-
- path: '^go/vt/vttablet/(.*endtoend.*|.*_test.go)'
173-
linters:
174-
- errcheck
175-
- path: '^go/vt/vttest'
176-
linters:
177-
- errcheck
178-
- path: '^go/vt/worker'
179-
linters:
180-
- errcheck
181-
- path: '^go/vt/workflow'
182-
linters:
183-
- errcheck
184-
- path: '^go/vt/wrangler'
185-
linters:
186-
- errcheck
187-
- path: '^go/vt/zkctl'
188-
linters:
189-
- errcheck
190-
### END: errcheck exclusion rules
191-
192-
# https://github.com/golangci/golangci/wiki/Configuration
193-
service:
194-
golangci-lint-version: 1.64.5 # use the fixed version to not introduce new linters unexpectedly
189+
settings:
190+
goimports:
191+
local-prefixes:
192+
- vitess.io/vitess
193+
exclusions:
194+
generated: lax
195+
paths:
196+
- third_party$
197+
- builtin$
198+
- examples$
199+
- ^go/vt/proto/

0 commit comments

Comments
 (0)
Please sign in to comment.