Skip to content

Commit c712a83

Browse files
committed
Update linter to v2.0.2
1 parent 8592022 commit c712a83

File tree

6 files changed

+114
-8
lines changed

6 files changed

+114
-8
lines changed

.github/workflows/workflow.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ jobs:
3838
with:
3939
go-version: 1.24.x
4040
- name: golangci-lint
41-
uses: golangci/golangci-lint-action@v6
41+
uses: golangci/golangci-lint-action@v7
4242
with:
4343
version: latest

.golangci.yaml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
version: "2"
2+
linters:
3+
default: all
4+
disable:
5+
- asasalint
6+
- asciicheck
7+
- bidichk
8+
- bodyclose
9+
- canonicalheader
10+
- containedctx
11+
- contextcheck
12+
- copyloopvar
13+
- cyclop
14+
- decorder
15+
- depguard
16+
- dogsled
17+
- dupl
18+
- dupword
19+
- durationcheck
20+
- err113
21+
- errcheck
22+
- errchkjson
23+
- errname
24+
- errorlint
25+
- exhaustive
26+
- exhaustruct
27+
- exptostd
28+
- fatcontext
29+
- forbidigo
30+
- forcetypeassert
31+
- funlen
32+
- ginkgolinter
33+
- gocheckcompilerdirectives
34+
- gochecknoglobals
35+
- gochecknoinits
36+
- gochecksumtype
37+
- gocognit
38+
- goconst
39+
- gocritic
40+
- gocyclo
41+
- godot
42+
- godox
43+
- goheader
44+
- gomoddirectives
45+
- gomodguard
46+
- goprintffuncname
47+
- gosec
48+
- gosmopolitan
49+
- govet
50+
- grouper
51+
- iface
52+
- importas
53+
- inamedparam
54+
- ineffassign
55+
- interfacebloat
56+
- intrange
57+
- ireturn
58+
- lll
59+
- loggercheck
60+
- maintidx
61+
- makezero
62+
- mirror
63+
- misspell
64+
- mnd
65+
- musttag
66+
- nakedret
67+
- nestif
68+
- nilerr
69+
- nilnesserr
70+
- nilnil
71+
- nlreturn
72+
- noctx
73+
- nolintlint
74+
- nonamedreturns
75+
- nosprintfhostport
76+
- paralleltest
77+
- perfsprint
78+
- prealloc
79+
- predeclared
80+
- promlinter
81+
- protogetter
82+
- reassign
83+
- recvcheck
84+
- revive
85+
- rowserrcheck
86+
- sloglint
87+
- spancheck
88+
- sqlclosecheck
89+
- staticcheck
90+
- tagalign
91+
- tagliatelle
92+
- testableexamples
93+
- testifylint
94+
- testpackage
95+
- thelper
96+
- tparallel
97+
- unparam
98+
- varnamelen
99+
- whitespace
100+
- wrapcheck
101+
- wsl
102+
- zerologlint

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ GOCMD=go
33
linters-install:
44
@golangci-lint --version >/dev/null 2>&1 || { \
55
echo "installing linting tools..."; \
6-
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s v1.41.1; \
6+
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s v2.0.2; \
77
}
88

99
lint: linters-install

baked_in.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ func parseOneOfParam2(s string) []string {
260260
oneofValsCacheRWLock.Lock()
261261
vals = splitParamsRegex().FindAllString(s, -1)
262262
for i := 0; i < len(vals); i++ {
263-
vals[i] = strings.Replace(vals[i], "'", "", -1)
263+
vals[i] = strings.ReplaceAll(vals[i], "'", "")
264264
}
265265
oneofValsCache[s] = vals
266266
oneofValsCacheRWLock.Unlock()
@@ -1619,7 +1619,9 @@ func isImage(fl FieldLevel) bool {
16191619
if err != nil {
16201620
return false
16211621
}
1622-
defer file.Close()
1622+
defer func() {
1623+
_ = file.Close()
1624+
}()
16231625

16241626
mime, err := mimetype.DetectReader(file)
16251627
if err != nil {

cache.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ func (v *Validate) parseFieldTagsRecursive(tag string, fieldName string, alias s
309309
}
310310

311311
if len(vals) > 1 {
312-
current.param = strings.Replace(strings.Replace(vals[1], utf8HexComma, ",", -1), utf8Pipe, "|", -1)
312+
current.param = strings.ReplaceAll(strings.ReplaceAll(vals[1], utf8HexComma, ","), utf8Pipe, "|")
313313
}
314314
}
315315
current.isBlockEnd = true

validator_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3088,7 +3088,7 @@ func TestBadKeyValidation(t *testing.T) {
30883088

30893089
func TestInterfaceErrValidation(t *testing.T) {
30903090
var v2 interface{} = 1
3091-
var v1 interface{} = v2
3091+
var v1 = v2
30923092

30933093
validate := New()
30943094
errs := validate.Var(v1, "len=1")
@@ -5990,7 +5990,8 @@ func TestImageValidation(t *testing.T) {
59905990
}
59915991
},
59925992
func() {
5993-
os.Remove(paths["png"])
5993+
err := os.Remove(paths["png"])
5994+
Equal(t, err, nil)
59945995
},
59955996
},
59965997
{
@@ -6007,7 +6008,8 @@ func TestImageValidation(t *testing.T) {
60076008
}
60086009
},
60096010
func() {
6010-
os.Remove(paths["jpeg"])
6011+
err := os.Remove(paths["jpeg"])
6012+
Equal(t, err, nil)
60116013
},
60126014
},
60136015
{

0 commit comments

Comments
 (0)