Skip to content

Commit 8a4dff4

Browse files
committed
update golangci to v2
1 parent 5483920 commit 8a4dff4

3 files changed

Lines changed: 118 additions & 119 deletions

File tree

.golangci.yml

Lines changed: 58 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,29 @@
11
# Code generated by gen-lint. DO NOT EDIT.
22

3+
version: "2"
4+
35
run:
46
timeout: 5m
57

68
issues:
79
# 显示所有 issue
810
max-issues-per-linter: 0
911
max-same-issues: 0
10-
exclude-use-default: false
12+
13+
formatters:
14+
# 必须在enable打开才能用
15+
enable:
16+
- gofmt
17+
- gci
18+
19+
settings:
20+
gci:
21+
sections:
22+
- standard
23+
- default
24+
- prefix(github.com/ifooth/devcontainer)
1125

1226
linters:
13-
disable-all: true
1427
enable:
1528
# enable by default
1629
- errcheck
@@ -21,65 +34,55 @@ linters:
2134
- unused
2235

2336
# custom
24-
- gci
2537
- goconst
26-
- gofmt
2738
- goheader
28-
- goimports
2939
- gosec
3040
- misspell
3141
- nakedret
3242
- revive
3343
- unconvert
3444
- unparam
3545

36-
linters-settings:
37-
# 只开启特定的规则
38-
errcheck:
39-
exclude-functions:
40-
- (*os.File).Close
41-
- (io.Closer).Close
42-
- (net/http.ResponseWriter).Write
43-
- io.Copy
44-
- os.RemoveAll
45-
govet:
46-
enable:
47-
- shadow
48-
goimports:
49-
local-prefixes: github.com/ifooth/devcontainer
50-
gci:
51-
sections:
52-
- standard
53-
- default
54-
- prefix(github.com/ifooth/devcontainer)
55-
gosec:
56-
includes:
57-
- G201 # SQL query construction using format string
58-
- G202 # SQL query construction using string concatenation
59-
- G101 # Look for hard coded credentials
60-
- G401 # Detect the usage of DES, RC4, MD5 or SHA1
61-
- G402 # Look for bad TLS connection settings
62-
- G403 # Ensure minimum RSA key length of 2048 bits
63-
- G404 # Insecure random number source (rand)
64-
- G504 # Import blocklist: net/http/cgi
65-
misspell:
66-
locale: US
67-
revive:
68-
rules:
69-
- name: line-length-limit
70-
arguments:
71-
- 160
72-
- name: function-length
73-
arguments:
74-
- 80 # statements
75-
- 120 # lines
76-
- name: cyclomatic
77-
arguments:
78-
- 30
79-
- name: use-any
80-
- name: early-return
81-
- name: exported
82-
arguments:
83-
- checkPrivateReceivers
84-
- sayRepetitiveInsteadOfStutters
85-
- name: package-comments
46+
settings:
47+
# 只开启特定的规则
48+
errcheck:
49+
exclude-functions:
50+
- (*os.File).Close
51+
- (io.Closer).Close
52+
- (net/http.ResponseWriter).Write
53+
- io.Copy
54+
- os.RemoveAll
55+
govet:
56+
enable:
57+
- shadow
58+
gosec:
59+
includes:
60+
- G201 # SQL query construction using format string
61+
- G202 # SQL query construction using string concatenation
62+
- G101 # Look for hard coded credentials
63+
- G401 # Detect the usage of DES, RC4, MD5 or SHA1
64+
- G402 # Look for bad TLS connection settings
65+
- G403 # Ensure minimum RSA key length of 2048 bits
66+
- G404 # Insecure random number source (rand)
67+
- G504 # Import blocklist: net/http/cgi
68+
misspell:
69+
locale: US
70+
revive:
71+
rules:
72+
- name: line-length-limit
73+
arguments:
74+
- 160
75+
- name: function-length
76+
arguments:
77+
- 80 # statements
78+
- 120 # lines
79+
- name: cyclomatic
80+
arguments:
81+
- 30
82+
- name: use-any
83+
- name: early-return
84+
- name: exported
85+
arguments:
86+
- checkPrivateReceivers
87+
- sayRepetitiveInsteadOfStutters
88+
- name: package-comments

cmd/gen-lint/main.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,8 @@ func main() {
5959
module := match[1]
6060
d := path.Dir(line)
6161
_, err = script.File(tmpl).
62-
Replace("# - gci", "- gci").
63-
Replace("# goimports", "goimports").
64-
Replace("# local-prefixes: github.com/ifooth/devcontainer", fmt.Sprintf(" local-prefixes: %s", module)).
65-
Replace("# gci", "gci").
66-
Replace("# sections", " sections").
67-
Replace("# - standard", " - standard").
68-
Replace("# - default", " - default").
69-
Replace("# - prefix(github.com/ifooth/devcontainer)", fmt.Sprintf(" - prefix(%s)", module)).
70-
Replace("run:", "# Code generated by gen-lint. DO NOT EDIT.\n\nrun:").
62+
Replace("github.com/ifooth/devcontainer", fmt.Sprintf("%s", module)).
63+
Replace("version:", "# Code generated by gen-lint. DO NOT EDIT.\n\nversion:").
7164
WriteFile(path.Join(d, "./.golangci.yml"))
7265
if err != nil {
7366
log.Fatalf("failed to write golangci.yml, err: %s", err)

root/.golangci.yml

Lines changed: 58 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,27 @@
1+
version: "2"
2+
13
run:
24
timeout: 5m
35

46
issues:
57
# 显示所有 issue
68
max-issues-per-linter: 0
79
max-same-issues: 0
8-
exclude-use-default: false
10+
11+
formatters:
12+
# 必须在enable打开才能用
13+
enable:
14+
- gofmt
15+
- gci
16+
17+
settings:
18+
gci:
19+
sections:
20+
- standard
21+
- default
22+
- prefix(github.com/ifooth/devcontainer)
923

1024
linters:
11-
disable-all: true
1225
enable:
1326
# enable by default
1427
- errcheck
@@ -19,65 +32,55 @@ linters:
1932
- unused
2033

2134
# custom
22-
# - gci
2335
- goconst
24-
- gofmt
2536
- goheader
26-
- goimports
2737
- gosec
2838
- misspell
2939
- nakedret
3040
- revive
3141
- unconvert
3242
- unparam
3343

34-
linters-settings:
35-
# 只开启特定的规则
36-
errcheck:
37-
exclude-functions:
38-
- (*os.File).Close
39-
- (io.Closer).Close
40-
- (net/http.ResponseWriter).Write
41-
- io.Copy
42-
- os.RemoveAll
43-
govet:
44-
enable:
45-
- shadow
46-
# goimports:
47-
# local-prefixes: github.com/ifooth/devcontainer
48-
# gci:
49-
# sections:
50-
# - standard
51-
# - default
52-
# - prefix(github.com/ifooth/devcontainer)
53-
gosec:
54-
includes:
55-
- G201 # SQL query construction using format string
56-
- G202 # SQL query construction using string concatenation
57-
- G101 # Look for hard coded credentials
58-
- G401 # Detect the usage of DES, RC4, MD5 or SHA1
59-
- G402 # Look for bad TLS connection settings
60-
- G403 # Ensure minimum RSA key length of 2048 bits
61-
- G404 # Insecure random number source (rand)
62-
- G504 # Import blocklist: net/http/cgi
63-
misspell:
64-
locale: US
65-
revive:
66-
rules:
67-
- name: line-length-limit
68-
arguments:
69-
- 160
70-
- name: function-length
71-
arguments:
72-
- 80 # statements
73-
- 120 # lines
74-
- name: cyclomatic
75-
arguments:
76-
- 30
77-
- name: use-any
78-
- name: early-return
79-
- name: exported
80-
arguments:
81-
- checkPrivateReceivers
82-
- sayRepetitiveInsteadOfStutters
83-
- name: package-comments
44+
settings:
45+
# 只开启特定的规则
46+
errcheck:
47+
exclude-functions:
48+
- (*os.File).Close
49+
- (io.Closer).Close
50+
- (net/http.ResponseWriter).Write
51+
- io.Copy
52+
- os.RemoveAll
53+
govet:
54+
enable:
55+
- shadow
56+
gosec:
57+
includes:
58+
- G201 # SQL query construction using format string
59+
- G202 # SQL query construction using string concatenation
60+
- G101 # Look for hard coded credentials
61+
- G401 # Detect the usage of DES, RC4, MD5 or SHA1
62+
- G402 # Look for bad TLS connection settings
63+
- G403 # Ensure minimum RSA key length of 2048 bits
64+
- G404 # Insecure random number source (rand)
65+
- G504 # Import blocklist: net/http/cgi
66+
misspell:
67+
locale: US
68+
revive:
69+
rules:
70+
- name: line-length-limit
71+
arguments:
72+
- 160
73+
- name: function-length
74+
arguments:
75+
- 80 # statements
76+
- 120 # lines
77+
- name: cyclomatic
78+
arguments:
79+
- 30
80+
- name: use-any
81+
- name: early-return
82+
- name: exported
83+
arguments:
84+
- checkPrivateReceivers
85+
- sayRepetitiveInsteadOfStutters
86+
- name: package-comments

0 commit comments

Comments
 (0)