-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy path.golangci.yml
More file actions
172 lines (164 loc) · 4.73 KB
/
Copy path.golangci.yml
File metadata and controls
172 lines (164 loc) · 4.73 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# golangci-lint configuration for x402 Go SDK
# See: https://golangci-lint.run/usage/configuration/
version: "2"
linters:
enable:
# Detect common mistakes with asynchronous code
- asasalint
# Check for non-ASCII identifiers
- asciicheck
# Detect dangerous Unicode characters (security)
- bidichk
# Detect unclosed HTTP response bodies
- bodyclose
# Detect loop variable capture issues (Go 1.22+)
- copyloopvar
# Check for time.Duration type misuse
- durationcheck
# Check error handling, wrapping, and type assertions
- errorlint
# Check compiler directives (//go:generate, etc.)
- gocheckcompilerdirectives
# Check logger calls for consistency
- loggercheck
# Ensure append results are assigned (prevent bugs)
- makezero
# Enforce struct tags in JSON/YAML marshaling
- musttag
# Find code that returns nil even on error paths
- nilerr
# Check for missing context.Context in HTTP requests
- noctx
# Ensure protobuf getters are used (avoid nil panics)
- protogetter
# Detect useless reassignments
- reassign
# Check sql.Rows.Err() is called
- rowserrcheck
# Detect unclosed sql.Rows
- sqlclosecheck
# Report unused function parameters
- unparam
# Additional linters for SDK quality
# Detect slice bound check issues
- sloglint
# Find ineffective assignments
- ineffassign
# Check for misspellings in comments
- misspell
# Detect naked returns in functions > 5 lines
- nakedret
# Check for Printf format string mismatches
- govet
# Detect suspicious constructs (e.g., empty branches)
- staticcheck
# Deprecated function and constant detection
- gocritic
# Check for unused exported symbols (important for SDK)
- unused
# Detect context.Context misuse
- contextcheck
exclusions:
# Relax checks for generated files
generated: lax
presets:
# Skip comment-related checks (godoc, etc.)
- comments
# Reduce common false positives
- common-false-positives
# Skip legacy linter rules
- legacy
# Relax standard error handling checks where appropriate
- std-error-handling
paths:
# Exclude generated files
- .*\.gen\.go$
- .*_gen\.go$
- .*_generated\.go$
# Exclude legacy code (separate module, may have different standards)
- legacy/
# Exclude test utilities and mocks
- test/mocks/
# Exclude template files (generated HTML content)
- http/.*_template\.go$
rules:
# Allow unused parameters in test files (common for table-driven tests)
- linters:
- unparam
path: _test\.go$
# Allow naked returns in short test helpers
- linters:
- nakedret
path: _test\.go$
# Allow magic numbers in test files
- linters:
- mnd
path: _test\.go$
# Reduce noise from gocritic in tests (if-else chains, etc.)
- linters:
- gocritic
path: _test\.go$
# Allow unchecked errors in test files (common pattern for test setup)
- linters:
- errcheck
path: _test\.go$
# Allow HTTP calls without context in test files
- linters:
- noctx
path: _test\.go$
# Allow staticcheck style issues in test files
- linters:
- staticcheck
path: _test\.go$
text: "ST1023"
# Allow ineffective assignments in test files (often intentional)
- linters:
- ineffassign
path: _test\.go$
# Allow unused code in test files (mock implementations, etc.)
- linters:
- unused
path: test/
# Allow error wrapping without %w in certain contexts
- linters:
- errorlint
text: "non-wrapping format verb"
# Gin context is passed by value intentionally
- linters:
- contextcheck
path: http/gin/
formatters:
exclusions:
generated: lax
paths:
# Exclude legacy code from formatting checks
- legacy/
# Exclude test mocks
- test/mocks/
# Exclude template files
- http/.*_template\.go$
output:
# Show all issues, not just first per line
show-stats: true
# Enable sorting
sort-results: true
# Sort by file, then line, then column
sort-order:
- file
- linter
issues:
# Report all issues (don't limit)
max-issues-per-linter: 0
max-same-issues: 0
# Include test files
exclude-dirs-use-default: false
# Faster linting by not analyzing dependencies
exclude-dirs:
- vendor
run:
# Timeout for linting (generous for large codebases)
timeout: 5m
# Use all available CPU cores
concurrency: 0
# Don't skip directories
allow-parallel-runners: true