Skip to content

Commit bc57e66

Browse files
committed
chore: update linter
1 parent d523ce5 commit bc57e66

File tree

4 files changed

+67
-74
lines changed

4 files changed

+67
-74
lines changed

.github/workflows/go-cross.yml

-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ on:
44
push:
55
branches:
66
- main
7-
- master
87
pull_request:
98
branches:
109
- main
11-
- master
1210

1311
jobs:
1412

.github/workflows/main.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ on:
44
push:
55
branches:
66
- main
7-
- master
87
pull_request:
98
branches:
109
- main
11-
- master
1210

1311
jobs:
1412

@@ -17,7 +15,7 @@ jobs:
1715
runs-on: ubuntu-latest
1816
env:
1917
GO_VERSION: stable
20-
GOLANGCI_LINT_VERSION: v1.63.4
18+
GOLANGCI_LINT_VERSION: v2.0.1
2119
CGO_ENABLED: 0
2220

2321
steps:

.golangci.yml

+65-68
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,80 @@
1+
version: "2"
2+
3+
formatters:
4+
enable:
5+
- gci
6+
- gofmt
7+
- gofumpt
8+
- goimports
9+
110
linters:
2-
enable-all: true
11+
default: all
312
disable:
4-
- exportloopref # deprecated
5-
- sqlclosecheck # not relevant (SQL)
6-
- rowserrcheck # not relevant (SQL)
713
- cyclop # duplicate of gocyclo
8-
- lll
914
- dupl
10-
- wsl
11-
- nlreturn
12-
- mnd
1315
- err113
14-
- wrapcheck
1516
- exhaustive
1617
- exhaustruct
17-
- testpackage
18-
- tparallel
19-
- paralleltest
20-
- prealloc
2118
- forcetypeassert
22-
- varnamelen
23-
- nilnil
2419
- ireturn
20+
- lll
21+
- mnd
22+
- nilnil
23+
- nlreturn
2524
- nonamedreturns
26-
27-
linters-settings:
28-
govet:
29-
enable:
30-
- shadow
31-
gocyclo:
32-
min-complexity: 20
33-
goconst:
34-
min-len: 5
35-
min-occurrences: 3
36-
misspell:
37-
locale: US
38-
funlen:
39-
lines: -1
40-
statements: 50
41-
godox:
42-
keywords:
43-
- FIXME
44-
depguard:
25+
- paralleltest
26+
- prealloc
27+
- rowserrcheck # not relevant (SQL)
28+
- sqlclosecheck # not relevant (SQL)
29+
- testpackage
30+
- tparallel
31+
- varnamelen
32+
- wrapcheck
33+
- wsl
34+
settings:
35+
depguard:
36+
rules:
37+
main:
38+
deny:
39+
- pkg: github.com/instana/testify
40+
desc: not allowed
41+
- pkg: github.com/pkg/errors
42+
desc: Should be replaced by standard lib errors package
43+
funlen:
44+
lines: -1
45+
statements: 50
46+
goconst:
47+
min-len: 5
48+
min-occurrences: 3
49+
gocyclo:
50+
min-complexity: 20
51+
godox:
52+
keywords:
53+
- FIXME
54+
govet:
55+
enable:
56+
- shadow
57+
misspell:
58+
locale: US
59+
perfsprint:
60+
err-error: true
61+
errorf: true
62+
sprintf1: true
63+
strconcat: false
64+
testifylint:
65+
disable:
66+
- require-error
67+
- go-require
68+
exclusions:
69+
presets:
70+
- std-error-handling
71+
- comments
4572
rules:
46-
main:
47-
deny:
48-
- pkg: "github.com/instana/testify"
49-
desc: not allowed
50-
- pkg: "github.com/pkg/errors"
51-
desc: Should be replaced by standard lib errors package
52-
testifylint:
53-
disable:
54-
- require-error
55-
- go-require
56-
perfsprint:
57-
err-error: true
58-
errorf: true
59-
sprintf1: true
60-
strconcat: false
73+
- linters:
74+
- funlen
75+
- goconst
76+
path: (.+)_test.go
6177

6278
issues:
63-
exclude-use-default: false
6479
max-issues-per-linter: 0
6580
max-same-issues: 0
66-
exclude:
67-
- "Error return value of .((os\\.)?std(out|err)\\..*|.*Close|.*Flush|os\\.Remove(All)?|.*printf?|os\\.(Un)?Setenv). is not checked"
68-
- "exported (type|method|function) (.+) should have comment or be unexported"
69-
exclude-rules:
70-
- path: (.+)_test.go
71-
linters:
72-
- funlen
73-
- goconst
74-
75-
output:
76-
show-stats: true
77-
sort-results: true
78-
sort-order:
79-
- file
80-
- linter
81-
82-
run:
83-
timeout: 5m

lib.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func GetFieldByTag(ival interface{}, tagName string, fieldNames []string) (inter
145145
rest := fieldNames[1:]
146146

147147
valType := val.Type()
148-
for i := 0; i < valType.NumField(); i++ {
148+
for i := range valType.NumField() {
149149
tagValue := valType.Field(i).Tag.Get(tagName)
150150

151151
parts := strings.Split(tagValue, ",")

0 commit comments

Comments
 (0)