Skip to content

Commit fd4a5eb

Browse files
authored
Refactor .golangci.yml for better formatting and settings
1 parent 1e4e62f commit fd4a5eb

1 file changed

Lines changed: 83 additions & 33 deletions

File tree

.golangci.yml

Lines changed: 83 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,24 @@ run:
55
go: "1.26"
66

77
formatters:
8-
enable: [goimports]
8+
enable:
9+
- goimports
910
settings:
1011
goimports:
11-
local-prefixes: [github.com/gosuda, gosuda.org]
12+
local-prefixes:
13+
- github.com/gosuda
14+
- gosuda.org
1215

1316
linters:
1417
default: standard
18+
1519
enable:
20+
# --- Tier 1: Bugs & Correctness ---
1621
- govet
1722
- errcheck
1823
- staticcheck
1924
- unused
25+
- gosec
2026
- errorlint
2127
- copyloopvar
2228
- nilerr
@@ -26,68 +32,112 @@ linters:
2632
- durationcheck
2733
- makezero
2834
- noctx
29-
- revive
35+
36+
# --- Tier 2: Code Quality & Style ---
37+
- gocritic
38+
- unconvert
39+
- unparam
3040
- wastedassign
3141
- misspell
3242
- whitespace
3343
- godot
44+
- goconst
45+
- dupword
3446
- usestdlibvars
3547
- testifylint
48+
- testableexamples
49+
- tparallel
3650
- usetesting
51+
52+
# --- Tier 3: Concurrency & Safety ---
53+
- gochecknoglobals
54+
- gochecknoinits
3755
- containedctx
56+
57+
# --- Tier 4: Performance & Modernization ---
3858
- prealloc
3959
- intrange
60+
- modernize
4061
- fatcontext
4162
- perfsprint
4263
- reassign
64+
- spancheck
4365
- mirror
66+
- recvcheck
4467

4568
exclusions:
4669
rules:
47-
- linters: [errcheck]
70+
- linters:
71+
- errcheck
4872
source: "^\\s*defer\\s+"
4973
- path: "_test\\.go"
50-
linters: [bodyclose, errcheck, noctx, wrapcheck, funlen, dupl]
51-
- text: "should have a package comment"
52-
linters: [revive]
53-
- text: "exported \\S+ \\S+ should have comment"
54-
linters: [revive]
74+
linters:
75+
- bodyclose
76+
- errcheck
77+
- gosec
78+
- noctx
79+
- wrapcheck
80+
- goconst
81+
- funlen
82+
- dupl
83+
- gochecknoglobals
5584

5685
settings:
57-
errcheck:
58-
check-blank: false
59-
check-type-assertions: false
60-
exclude-functions:
61-
- fmt.Printf
62-
- fmt.Println
63-
- fmt.Print
64-
- fmt.Fprintf
65-
- fmt.Fprint
66-
- fmt.Fprintln
67-
- fmt.Sprintf
68-
- os.Unsetenv
69-
- encoding/json.Marshal
70-
- encoding/json.Unmarshal
71-
- io.Copy
72-
- log.Printf
73-
- log.Println
74-
- log.Print
75-
- time.Now
76-
- time.Sleep
77-
- sync.Mutex.Lock
78-
- sync.Mutex.Unlock
79-
- sync.RWMutex.RLock
80-
- sync.RWMutex.RUnlock
86+
# errcheck:
87+
# check-blank: false
88+
# check-type-assertions: false
89+
# exclude-functions:
90+
# - fmt.Printf
91+
# - fmt.Println
92+
# - fmt.Print
93+
# - fmt.Fprintf
94+
# - fmt.Fprint
95+
# - fmt.Fprintln
96+
# - fmt.Sprintf
97+
# - os.Unsetenv
98+
# - encoding/json.Marshal
99+
# - encoding/json.Unmarshal
100+
# - encoding/json.NewEncoder
101+
# - encoding/json.NewDecoder
102+
# - strings.Builder.WriteString
103+
# - strings.Builder.Write
104+
# - bytes.Buffer.Write
105+
# - bytes.Buffer.WriteString
106+
# - io.Copy
107+
# - log.Printf
108+
# - log.Println
109+
# - log.Print
110+
# - time.Now
111+
# - time.Sleep
112+
113+
gocritic:
114+
enabled-tags:
115+
- diagnostic
116+
- style
117+
- performance
118+
- opinionated
119+
disabled-checks:
120+
- hugeParam
121+
- rangeValCopy
81122

82123
govet:
83124
enable-all: true
125+
settings:
126+
shadow:
127+
strict: true
84128

85129
perfsprint:
86130
strconcat: true
87131

88132
fatcontext:
89133
check-struct-pointers: true
90134

135+
spancheck:
136+
checks:
137+
- end
138+
- record-error
139+
- set-status
140+
91141
issues:
92142
max-issues-per-linter: 0
93143
max-same-issues: 0

0 commit comments

Comments
 (0)