1+ # yaml-language-server: $schema=https://golangci-lint.run/jsonschema/golangci.jsonschema.json
2+ # golangci-lint configuration for github.com/ralvarezdev/go-loader
3+ # Based on v2.5.0 best practices
4+ # Last updated: 2025-10-21
5+
6+ version : " 2"
7+
8+ run :
9+ timeout : 5m
10+ concurrency : 0 # Auto-detect CPU cores
11+ tests : true
12+ modules-download-mode : readonly
13+ go : ' 1.25.1' # Match your project's Go version
14+ relative-path-mode : gomod
15+
16+ output :
17+ formats :
18+ text :
19+ path : stdout
20+ print-linter-name : true
21+ colors : true
22+ sort-order :
23+ - severity
24+ - linter
25+ - file
26+ show-stats : true
27+
28+ formatters :
29+ enable :
30+ - goimports
31+ - golines
32+
33+ settings :
34+ goimports :
35+ local-prefixes :
36+ - github.com/ralvarezdev/go-loader
37+
38+ golines :
39+ max-len : 120
40+ shorten-comments : true
41+
42+ exclusions :
43+ generated : lax
44+ paths :
45+ - " vendor/"
46+ - " third_party/"
47+
48+ linters :
49+ enable :
50+ # Essential Linters
51+ - govet
52+ - staticcheck
53+ - unused
54+ - goconst
55+ - godoclint
56+ - sloglint
57+ - misspell
58+
59+ # Security Linters
60+ - gosec
61+ - bidichk
62+
63+ # Resource Management
64+ - bodyclose
65+ - sqlclosecheck
66+ - rowserrcheck
67+
68+ # Error Handling Linters
69+ - errorlint
70+ - errcheck
71+ - nilerr
72+ - nilnil
73+
74+ # Code Quality
75+ - dupl
76+ - nestif
77+ - ineffassign
78+ - revive
79+ - gocritic
80+ - unconvert
81+ - wastedassign
82+ - usestdlibvars
83+
84+ # Context & Concurrency
85+ - contextcheck
86+ - noctx
87+
88+ # OPTIONAL - Testing (if using testify)
89+ # - testifylint
90+ # - thelper
91+
92+ settings :
93+ govet :
94+ enable :
95+ - shadow
96+ # - fieldalignment # Enable for performance-critical code
97+ settings :
98+ shadow :
99+ strict : true
100+
101+ errcheck :
102+ check-type-assertions : true
103+ check-blank : true
104+ exclude-functions :
105+ - io.Copy(*bytes.Buffer)
106+ - io.Copy(os.Stdout)
107+ - (*net/http.ResponseWriter).Write
108+
109+ staticcheck :
110+ checks :
111+ - " all"
112+ - " -SA1019" # Deprecation warnings (noisy during refactoring)
113+ - " -ST1000" # Package comment requirements
114+ - " -ST1003" # Underscore naming (conflicts with protobuf)
115+ - " -ST1016" # Receiver naming rules
116+
117+ goconst :
118+ min-len : 3
119+ min-occurrences : 3
120+ ignore-string-values :
121+ - ' http.*'
122+ - ' ^test.*'
123+ - ' .*\.proto$'
124+
125+ godoclint :
126+ default : basic
127+ disable :
128+ - require-pkg-doc
129+
130+ sloglint :
131+ no-global : " all"
132+ static-msg : true
133+ key-naming-case : " snake"
134+ forbidden-keys :
135+ - time
136+ - level
137+ - msg
138+ - source
139+
140+ misspell :
141+ locale : US
142+ mode : restricted
143+ ignore-rules :
144+ - referer
145+ - kubernetes
146+ - grpc
147+ - protobuf
148+
149+ dupl :
150+ threshold : 100
151+
152+ nestif :
153+ min-complexity : 4
154+
155+ nilnil :
156+ only-two : true
157+ detect-opposite : true
158+
159+ gosec :
160+ excludes :
161+ - G104 # Duplicate of errcheck
162+ includes :
163+ - G201 # SQL injection
164+ - G202 # SQL injection
165+ - G204 # Command injection
166+ - G301 # File permissions
167+ - G302 # File permissions
168+ - G304 # File inclusion
169+ - G401 # Weak crypto
170+ - G402 # TLS InsecureSkipVerify
171+
172+ errorlint :
173+ errorf : true
174+ asserts : true
175+ comparison : true
176+
177+ revive :
178+ rules :
179+ # Error handling
180+ - name : error-return
181+ - name : error-strings
182+ - name : error-naming
183+
184+ # Code quality
185+ - name : if-return
186+ - name : increment-decrement
187+ - name : indent-error-flow
188+ - name : superfluous-else
189+ - name : unreachable-code
190+
191+ # Style
192+ - name : var-naming
193+ - name : range
194+ - name : receiver-naming
195+ - name : blank-imports
196+ - name : context-as-argument
197+ - name : dot-imports
198+ - name : empty-block
199+
200+ # Disable noisy rules
201+ - name : exported
202+ disabled : true
203+ - name : package-comments
204+ disabled : true
205+ - name : unused-parameter
206+ disabled : true
207+
208+ gocritic :
209+ enabled-tags :
210+ - diagnostic
211+ - style
212+ - performance
213+ disabled-checks :
214+ - commentFormatting
215+ - whyNoLint
216+
217+ exclusions :
218+ warn-unused : true
219+
220+ presets :
221+ - common-false-positives
222+ - std-error-handling
223+
224+ rules :
225+ # Test file exclusions
226+ - path : ' _test\.go'
227+ linters :
228+ - dupl
229+ - errcheck
230+ - nestif
231+ - goconst
232+ - gosec
233+ - funlen
234+ - gocyclo
235+
236+ # Generated code
237+ - path : ' \.pb\.go$'
238+ linters :
239+ - all
240+
241+ - path : ' mock_.+\.go$'
242+ linters :
243+ - all
244+
245+ # Long lines in go:generate
246+ - linters :
247+ - lll
248+ source : ' ^//go:generate '
249+
250+ # SQL linter false positives for repository pattern
251+ - text : " Rows/Stmt was not closed"
252+ path : _repository\.go$
253+ linters :
254+ - sqlclosecheck
255+
256+ issues :
257+ max-issues-per-linter : 0
258+ max-same-issues : 50
259+ uniq-by-line : true
260+
261+ # For gradual adoption on legacy codebases
262+ # new-from-rev: HEAD
263+ # new-from-merge-base: main
264+
265+ severity :
266+ default : error
267+
268+ rules :
269+ # Informational linters
270+ - linters :
271+ - dupl
272+ - goconst
273+ severity : info
274+
275+ # Security linters use their own severity
276+ - linters :
277+ - gosec
278+ severity : " @linter"
0 commit comments