-
Notifications
You must be signed in to change notification settings - Fork 114
/
.golangci.yml
118 lines (102 loc) · 2.92 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
# For the full list of configuration options, see
# https://github.com/golangci/golangci-lint#config-file
# See more about these linters at https://golangci-lint.run/usage/linters/
linters:
fast: false
disable-all: true
enable:
# golangci enables these by default.
- errcheck
- gofumpt # (replaces gofmt)
- gosimple
- govet
- ineffassign
- staticcheck
- typecheck
- unused
# golangci disables these by default, but we use them.
- bodyclose
- depguard
- durationcheck
- errorlint
- exportloopref
- gocritic
- nakedret
- stylecheck
- unconvert
- unparam
- whitespace
- forbidigo
linters-settings:
errcheck:
check-type-assertions: true # check for a := b.(T)
errorlint:
errorf: false # it's valid to use %v instead of %w
govet:
check-shadowing: true
enable-all: true
# We have a ton of test-only packages; but make sure we keep prod deps small.
depguard:
rules:
main:
list-mode: strict
files: $all
allow:
- $gostd
- github.com/Khan/genqlient
- github.com/vektah/gqlparser/v2
- golang.org/x/tools
- gopkg.in/yaml.v2
- github.com/alexflint/go-arg
- github.com/bmatcuk/doublestar/v4
- github.com/google/uuid
forbidigo:
forbid:
- '^print(|f|ln)$'
- '^fmt\.Print(|f|ln)$'
gocritic:
# Which checks should be enabled:
# See https://go-critic.github.io/overview#checks-overview
# and https://github.com/go-critic/go-critic#usage -> section "Tags".
# To check which checks are enabled: `GL_DEBUG=gocritic golangci-lint run`
enabled-tags:
- diagnostic
- performance
- style
disabled-checks:
- builtinShadow
- commentedOutCode
- importShadow
- paramTypeCombine
- unnamedResult
- ifElseChain
- sloppyReassign
- typeDefFirst
settings: # settings passed to gocritic
captLocal: # must be valid enabled check name
paramsOnly: true
issues:
exclude-rules:
# Test-only deps are not restricted.
- linters:
- depguard
path: _test\.go$|^internal/testutil/|^internal/integration/
# Ok to use fmt.Print in the examples, and in the CLI entrypoint.
- linters:
- forbidigo
path: ^example/|^generate/main\.go$
- linters:
- errcheck
path: _test\.go$
# Unchecked type-asserts are ok in tests -- a panic will be plenty clear.
# An error message with no function name means an unchecked type-assert.
text: "^Error return value is not checked$"
# Don't error if a test setup function always takes the same arguments.
- linters:
- unparam
path: _test\.go$
- linters:
- govet
# Only a big deal for runtime code.
path: ^generate/|^example/
text: "^fieldalignment: struct with \\d+ pointer bytes could be \\d+$"