Skip to content

Commit b651a19

Browse files
committed
Upgrade to golangci-lint v2
1 parent 77feac3 commit b651a19

File tree

3 files changed

+179
-194
lines changed

3 files changed

+179
-194
lines changed

.golangci.toml

Lines changed: 0 additions & 192 deletions
This file was deleted.

.golangci.yml

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
version: "2"
2+
run:
3+
go: "1.24"
4+
tests: true
5+
allow-parallel-runners: true
6+
linters:
7+
default: all
8+
disable:
9+
- cyclop
10+
- depguard
11+
- err113
12+
- exhaustive
13+
- exhaustruct
14+
- forcetypeassert
15+
- funlen
16+
- gochecknoglobals
17+
- gocognit
18+
- godox
19+
- gosmopolitan
20+
- inamedparam
21+
- interfacebloat
22+
- mnd
23+
- nlreturn
24+
- nonamedreturns
25+
- paralleltest
26+
# Seems to conflict with golines or one of the formatters.
27+
- tagalign
28+
- testpackage
29+
- thelper
30+
- varnamelen
31+
- wrapcheck
32+
- wsl
33+
- wsl_v5
34+
settings:
35+
errorlint:
36+
errorf: true
37+
asserts: true
38+
comparison: true
39+
exhaustive:
40+
default-signifies-exhaustive: true
41+
forbidigo:
42+
forbid:
43+
- pattern: Geoip
44+
msg: you should use `GeoIP`
45+
- pattern: geoIP
46+
msg: you should use `geoip`
47+
- pattern: Maxmind
48+
msg: you should use `MaxMind`
49+
- pattern: ^maxMind
50+
msg: you should use `maxmind`
51+
- pattern: Minfraud
52+
msg: you should use `MinFraud`
53+
- pattern: ^minFraud
54+
msg: you should use `minfraud`
55+
- pattern: ^math.Max$
56+
msg: you should use the max built-in instead.
57+
- pattern: ^math.Min$
58+
msg: you should use the min built-in instead.
59+
- pattern: ^os.IsNotExist
60+
msg: As per their docs, new code should use errors.Is(err, fs.ErrNotExist).
61+
- pattern: ^os.IsExist
62+
msg: As per their docs, new code should use errors.Is(err, fs.ErrExist)
63+
gosec:
64+
excludes:
65+
- G115
66+
govet:
67+
disable:
68+
- shadow
69+
enable-all: true
70+
lll:
71+
line-length: 120
72+
tab-width: 4
73+
misspell:
74+
locale: US
75+
extra-words:
76+
- typo: marshall
77+
correction: marshal
78+
- typo: marshalling
79+
correction: marshaling
80+
- typo: marshalls
81+
correction: marshals
82+
- typo: unmarshall
83+
correction: unmarshal
84+
- typo: unmarshalling
85+
correction: unmarshaling
86+
- typo: unmarshalls
87+
correction: unmarshals
88+
nolintlint:
89+
require-explanation: true
90+
require-specific: true
91+
allow-no-explanation:
92+
- lll
93+
- misspell
94+
allow-unused: false
95+
revive:
96+
severity: warning
97+
enable-all-rules: true
98+
rules:
99+
- name: add-constant
100+
disabled: true
101+
- name: cognitive-complexity
102+
disabled: true
103+
- name: confusing-naming
104+
disabled: true
105+
- name: confusing-results
106+
disabled: true
107+
- name: cyclomatic
108+
disabled: true
109+
- name: deep-exit
110+
disabled: true
111+
- name: flag-parameter
112+
disabled: true
113+
- name: function-length
114+
disabled: true
115+
- name: function-result-limit
116+
disabled: true
117+
- name: line-length-limit
118+
disabled: true
119+
- name: max-public-structs
120+
disabled: true
121+
- name: nested-structs
122+
disabled: true
123+
- name: unchecked-type-assertion
124+
disabled: true
125+
- name: unhandled-error
126+
disabled: true
127+
tagliatelle:
128+
case:
129+
rules:
130+
avro: snake
131+
bson: snake
132+
env: upperSnake
133+
envconfig: upperSnake
134+
json: snake
135+
mapstructure: snake
136+
xml: snake
137+
yaml: snake
138+
unparam:
139+
check-exported: true
140+
exclusions:
141+
generated: lax
142+
presets:
143+
- comments
144+
- common-false-positives
145+
- legacy
146+
- std-error-handling
147+
rules:
148+
- linters:
149+
- govet
150+
- revive
151+
path: _test.go
152+
text: 'fieldalignment:'
153+
paths:
154+
- third_party$
155+
- builtin$
156+
- examples$
157+
formatters:
158+
enable:
159+
- gci
160+
- gofmt
161+
- gofumpt
162+
- goimports
163+
- golines
164+
settings:
165+
gci:
166+
sections:
167+
- standard
168+
- default
169+
- prefix(github.com/oschwald/geoip2-golang)
170+
gofumpt:
171+
extra-rules: true
172+
exclusions:
173+
generated: lax
174+
paths:
175+
- third_party$
176+
- builtin$
177+
- examples$

reader_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ func BenchmarkCity(b *testing.B) {
271271
var city *City
272272

273273
ip := make(net.IP, 4)
274-
for i := 0; i < b.N; i++ {
274+
for range b.N {
275275
randomIPv4Address(r, ip)
276276
city, err = db.City(ip)
277277
if err != nil {
@@ -297,7 +297,7 @@ func BenchmarkASN(b *testing.B) {
297297
var asn *ASN
298298

299299
ip := make(net.IP, 4)
300-
for i := 0; i < b.N; i++ {
300+
for range b.N {
301301
randomIPv4Address(r, ip)
302302
asn, err = db.ASN(ip)
303303
if err != nil {

0 commit comments

Comments
 (0)