-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.golangci.yml
141 lines (137 loc) · 3.6 KB
/
.golangci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
run:
skip-dirs: # sets the directories to ignore
- util
- .*~
- api/swagger/docs
skip-files: # Set the go source files that do not need to be checked to support regular matching
- ".*.my.go$"
- ".*.pb.go$"
- _test.go
linters:
# please, do not use `enable-all`: it's deprecated and will be removed soon.
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
disable-all: true
enable:
- bodyclose
- depguard
- dogsled
- dupl
- errcheck
- funlen
- goconst
- gocritic
- gocyclo
- gofmt
- goimports
- goprintffuncname
- gosimple
- govet
- ineffassign
# - misspell
- nolintlint
- revive
# - rowserrcheck
# - staticcheck
# - structcheck
# - stylecheck
- typecheck
- unconvert
- unparam
- unused
- whitespace
issues:
# Excluding configuration per-path, per-linter, per-text and per-source
include:
- EXC0002 # disable excluding of issues about comments from golint
exclude-rules:
- linters:
- stylecheck
text: "ST1000:"
- path: _test\.go
linters:
- gomnd
- funlen
- goconst
# https://github.com/go-critic/go-critic/issues/926
- linters:
- gocritic
text: "unnecessaryDefer:"
linters-settings:
# errcheck:
# check-type-assertions: true # 这里建议设置为true,如果确实不需要检查,可以写成`num, _ := strconv.Atoi(numStr)`
# check-blank: false
lll:
line-length: 240 # the length of a line
godox:
keywords: # It is recommended to set to BUG, FIXME, OPTIMIZE, HACK
- BUG
- FIXME
- OPTIMIZE
- HACK
misspell:
locale: US
ignore-words:
- cancelled
goimports:
local-prefixes: github.com/houseme/union-jd-go
godot:
# Comments to be checked: `declarations`, `toplevel`, or `all`.
# Default: declarations
scope: toplevel
exclude:
# Exclude sentence fragments for lists.
- '^[ ]*[-•]'
# Exclude sentences prefixing a list.
- ':$'
# Check that each sentence ends with a period.
# Default: true
period: false
# Check that each sentence starts with a capital letter.
# Default: false
capital: false
revive:
ignore-generated-header: true
severity: error
rules:
- name: atomic
- name: line-length-limit
severity: error
arguments: [ 180 ]
- name: unhandled-error
arguments: [ "fmt.Printf", "myFunction" ]
- name: var-naming
severity: warning
disabled: false
arguments:
- [ "ID","URL","IP","HTTP","JSON","API","UID","Id","Api","Uid","Http","Json","Ip","Url" ] # AllowList
- [ "VM" ] # DenyList
- name: string-format
severity: warning
disabled: false
arguments:
- - 'core.WriteError[1].Message'
- '/^([^A-Z]|$)/'
- must not start with a capital letter
- - 'fmt.Errorf[0]'
- '/(^|[^\.!?])$/'
- must not end in punctuation
- - panic
- '/^[^\n]*$/'
- must not contain line breaks
- name: function-result-limit
severity: warning
disabled: false
arguments: [ 4 ]
funlen:
# Checks the number of lines in a function.
# If lower than 0, disable the check.
# Default: 60
lines: 160
# Checks the number of statements in a function.
# If lower than 0, disable the check.
# Default: 40
statements: 160
goconst:
# Ignore test files.
# Default: false
ignore-tests: true