Skip to content

Commit 9f24f4b

Browse files
committed
add missing files
1 parent e126d00 commit 9f24f4b

File tree

8 files changed

+2620
-0
lines changed

8 files changed

+2620
-0
lines changed

.golangci.yml

Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
## Golden config for golangci-lint - strict, but within the realm of what Go authors might use.
2+
#
3+
# This is tied to the version of golangci-lint listed in the Makefile, usage with other
4+
# versions of golangci-lint will yield errors and/or false positives.
5+
#
6+
# Docs: https://github.com/golangci/golangci-lint/blob/HEAD/.golangci.reference.yml
7+
# Based heavily on https://gist.github.com/maratori/47a4d00457a92aa426dbd48a18776322
8+
9+
version: "2"
10+
11+
issues:
12+
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
13+
max-issues-per-linter: 0
14+
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
15+
max-same-issues: 0
16+
17+
formatters:
18+
enable:
19+
# - gci
20+
# - gofmt
21+
- gofumpt
22+
# - goimports
23+
# - golines
24+
- swaggo
25+
26+
settings:
27+
golines:
28+
# Default: 100
29+
max-len: 120
30+
31+
linters:
32+
default: all
33+
disable:
34+
# linters that give advice contrary to what the Go authors advise
35+
- decorder # checks declaration order and count of types, constants, variables and functions
36+
- dupword # [useless without config] checks for duplicate words in the source code
37+
- exhaustruct # [highly recommend to enable] checks if all structure fields are initialized
38+
- forcetypeassert # [replaced by errcheck] finds forced type assertions
39+
- ginkgolinter # [if you use ginkgo/gomega] enforces standards of using ginkgo and gomega
40+
- gochecknoglobals # checks that no global variables exist
41+
- cyclop # replaced by revive
42+
- gocyclo # replaced by revive
43+
- funlen # replaced by revive
44+
- godox # TODO's are OK
45+
- ireturn # It's OK
46+
- musttag
47+
- nonamedreturns
48+
- goconst # finds repeated strings that could be replaced by a constant
49+
- goheader # checks is file header matches to pattern
50+
- gomodguard # [use more powerful depguard] allow and block lists linter for direct Go module dependencies
51+
- gomoddirectives
52+
- err113 # bad advice about dynamic errors
53+
- lll # [replaced by golines] reports long lines
54+
- mnd # detects magic numbers, duplicated by revive
55+
- nlreturn # [too strict and mostly code is not more readable] checks for a new line before return and branch statements to increase code clarity
56+
- noinlineerr # disallows inline error handling `if err := ...; err != nil {`
57+
- prealloc # [premature optimization, but can be used in some cases] finds slice declarations that could potentially be preallocated
58+
- tagliatelle # needs configuration
59+
- testableexamples # checks if examples are testable (have an expected output)
60+
- testpackage # makes you use a separate _test package
61+
- paralleltest # not every test should be in parallel
62+
- wrapcheck # not required
63+
- wsl # [too strict and mostly code is not more readable] whitespace linter forces you to use empty lines
64+
- wsl_v5 # [too strict and mostly code is not more readable] add or remove empty lines
65+
- zerologlint # detects the wrong usage of zerolog that a user forgets to dispatch zerolog.Event
66+
67+
# All settings can be found here https://github.com/golangci/golangci-lint/blob/HEAD/.golangci.reference.yml
68+
settings:
69+
depguard:
70+
rules:
71+
"deprecated":
72+
files:
73+
- "$all"
74+
deny:
75+
- pkg: github.com/golang/protobuf
76+
desc: Use google.golang.org/protobuf instead, see https://developers.google.com/protocol-buffers/docs/reference/go/faq#modules
77+
- pkg: github.com/satori/go.uuid
78+
desc: Use github.com/google/uuid instead, satori's package is not maintained
79+
- pkg: github.com/gofrs/uuid$
80+
desc: Use github.com/gofrs/uuid/v5 or later, it was not a go module before v5
81+
"non-test files":
82+
files:
83+
- "!$test"
84+
deny:
85+
- pkg: math/rand$
86+
desc: Use math/rand/v2 instead, see https://go.dev/blog/randv2
87+
- pkg: "github.com/sirupsen/logrus"
88+
desc: not allowed
89+
- pkg: "github.com/pkg/errors"
90+
desc: Should be replaced by standard lib errors package
91+
92+
dupl:
93+
# token count (default: 150)
94+
threshold: 300
95+
96+
embeddedstructfieldcheck:
97+
# Checks that sync.Mutex and sync.RWMutex are not used as embedded fields.
98+
forbid-mutex: true
99+
100+
errcheck:
101+
# Report about not checking of errors in type assertions: `a := b.(MyStruct)`.
102+
check-type-assertions: true
103+
check-blank: true
104+
105+
exhaustive:
106+
# Program elements to check for exhaustiveness.
107+
# Default: [ switch ]
108+
check:
109+
- switch
110+
- map
111+
default-signifies-exhaustive: true
112+
113+
fatcontext:
114+
# Check for potential fat contexts in struct pointers.
115+
# May generate false positives.
116+
# Default: false
117+
check-struct-pointers: true
118+
119+
funcorder:
120+
# Checks if the exported methods of a structure are placed before the non-exported ones.
121+
struct-method: false
122+
123+
gocognit:
124+
min-complexity: 55
125+
126+
gocritic:
127+
enable-all: true
128+
disabled-checks:
129+
- paramTypeCombine
130+
# The list of supported checkers can be found at https://go-critic.com/overview.
131+
settings:
132+
captLocal:
133+
# Whether to restrict checker to params only.
134+
paramsOnly: false
135+
underef:
136+
# Whether to skip (*x).method() calls where x is a pointer receiver.
137+
skipRecvDeref: false
138+
hugeParam:
139+
# Default: 80
140+
sizeThreshold: 200
141+
142+
govet:
143+
enable-all: true
144+
145+
godot:
146+
scope: toplevel
147+
148+
inamedparam:
149+
# Skips check for interface methods with only a single parameter.
150+
skip-single-param: true
151+
152+
nakedret:
153+
# Default: 30
154+
max-func-lines: 4
155+
156+
nestif:
157+
min-complexity: 12
158+
159+
nolintlint:
160+
# Exclude following linters from requiring an explanation.
161+
# Default: []
162+
allow-no-explanation: [funlen, gocognit, golines]
163+
# Enable to require an explanation of nonzero length after each nolint directive.
164+
require-explanation: true
165+
# Enable to require nolint directives to mention the specific linter being suppressed.
166+
require-specific: true
167+
168+
revive:
169+
enable-all-rules: true
170+
rules:
171+
- name: add-constant
172+
severity: warning
173+
disabled: false
174+
exclude: [""]
175+
arguments:
176+
- max-lit-count: "5"
177+
allow-strs: '"","\n"'
178+
allow-ints: "0,1,2,3,24,30,365,1024,0o600,0o700,0o750,0o755"
179+
allow-floats: "0.0,0.,1.0,1.,2.0,2."
180+
- name: cognitive-complexity
181+
arguments: [55]
182+
- name: cyclomatic
183+
arguments: [60]
184+
- name: function-length
185+
arguments: [150, 225]
186+
- name: line-length-limit
187+
arguments: [150]
188+
- name: nested-structs
189+
disabled: true
190+
- name: max-public-structs
191+
arguments: [10]
192+
- name: flag-parameter # fixes are difficult
193+
disabled: true
194+
195+
rowserrcheck:
196+
# database/sql is always checked.
197+
# Default: []
198+
packages:
199+
- github.com/jmoiron/sqlx
200+
201+
perfsprint:
202+
# optimize fmt.Sprintf("x: %s", y) into "x: " + y
203+
strconcat: false
204+
205+
staticcheck:
206+
checks:
207+
- all
208+
209+
usetesting:
210+
# Enable/disable `os.TempDir()` detections.
211+
# Default: false
212+
os-temp-dir: true
213+
214+
varnamelen:
215+
max-distance: 40
216+
min-name-length: 2
217+
218+
exclusions:
219+
# Default: []
220+
presets:
221+
- common-false-positives
222+
rules:
223+
# Allow "err" and "ok" vars to shadow existing declarations, otherwise we get too many false positives.
224+
- text: '^shadow: declaration of "(err|ok)" shadows declaration'
225+
linters:
226+
- govet
227+
- text: "parameter 'ctx' seems to be unused, consider removing or renaming it as _"
228+
linters:
229+
- revive
230+
- path: _test\.go
231+
linters:
232+
- dupl
233+
- gosec
234+
- godot
235+
- govet # alignment
236+
- noctx
237+
- perfsprint
238+
- revive
239+
- varnamelen

0 commit comments

Comments
 (0)