-
Notifications
You must be signed in to change notification settings - Fork 136
Expand file tree
/
Copy path.golangci.yml
More file actions
120 lines (116 loc) · 3.85 KB
/
Copy path.golangci.yml
File metadata and controls
120 lines (116 loc) · 3.85 KB
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
# yaml-language-server: $schema=https://www.schemastore.org/golangci-lint.json
# see https://golangci-lint.run/usage/configuration/ for documentation
---
version: "2"
linters:
# Only enable forbidigo and usetesting explicitly. The v2 defaults (errcheck, gosimple,
# govet, ineffassign, staticcheck, unused) are implicitly enabled to match v1 behavior.
enable:
- forbidigo
- usetesting
settings:
# Configure default linters to match v1 behavior (less strict)
errcheck:
# Don't check for errors in defer statements and common safe-to-ignore functions
check-type-assertions: false
check-blank: false
exclude-functions:
- io.Copy
- (io.Closer).Close
- (io.ReadCloser).Close
- (io.WriteCloser).Close
- (*os.File).Close
- (*database/sql.Rows).Close
- (*database/sql.Stmt).Close
- fmt.Fprint
- fmt.Fprintf
- fmt.Fprintln
- (net.Conn).Close
- (net.Listener).Close
- (*net.TCPListener).Close
- (*crypto/tls.Conn).Close
- (*archive/zip.Writer).Close
- os.Remove
- os.RemoveAll
- os.Setenv
- os.Unsetenv
govet:
# Only run a subset of analyzers to match v1 behavior
# Disable the 'inline' analyzer: it surfaces unfixable diagnostics for
# stdlib generic functions carrying '//go:fix inline' directives (e.g.
# slices.Contains, maps.Clear), which the inliner cannot rewrite because
# type parameter inference is not yet supported.
disable:
- inline
enable:
- asmdecl
- assign
- atomic
- bools
- buildtag
- cgocall
- composites
- copylocks
- errorsas
- httpresponse
- loopclosure
- lostcancel
- nilfunc
- printf
- shift
- stdmethods
- structtag
- tests
- unmarshal
- unreachable
- unsafeptr
- unusedresult
staticcheck:
# Use the same checks as v1 (disable newer style/quickfix checks)
# QF rules are "quickfix" suggestions that weren't in v1
# ST rules are style checks that are often too pedantic
checks:
[
"all",
"-ST1000",
"-ST1003",
"-ST1005",
"-ST1016",
"-ST1019",
"-ST1020",
"-ST1021",
"-ST1022",
"-ST1023",
"-QF1001",
"-QF1003",
"-QF1004",
"-QF1007",
"-QF1008",
"-QF1011",
"-QF1012",
]
forbidigo:
# Forbid the following identifiers (list of regexp)
#
# Add a comment to the offending line with '//nolint:forbidigo' to suppress the rule if
# you're working inside the main() function.
forbid:
# These APIs exit the process. These are OK to use in the main() function,
# and not ANYWHERE else.
- pattern: 'os\.Exit'
msg: "# Do not use except for inside main(). Suppress this message with //nolint:forbidigo at the end of the line if it is correct."
- pattern: 'log\.Fatal(f|ln)?'
msg: "# Do not use except for inside main(). Suppress this message with //nolint:forbidigo at the end of the line if it is correct."
usetesting:
# Tests must use the test-scoped context so work started by a test is cancelled with it.
# Suppress with '//nolint:usetesting' when a context must outlive the test, for example
# inside t.Cleanup (t.Context() is cancelled before cleanup runs) or in a detached goroutine.
context-background: true
context-todo: true
# The os.* checks below are unrelated to context handling; leave them off to keep this
# linter focused.
os-chdir: false
os-create-temp: false
os-mkdir-temp: false
os-setenv: false
os-temp-dir: false