Skip to content

Commit ce4d377

Browse files
authored
chore: Add golangci-lint workflow and config file (#11)
* add golangci-lint workflow and config file * go version mismatch * whitespace
1 parent b7c72f0 commit ce4d377

File tree

4 files changed

+155
-4
lines changed

4 files changed

+155
-4
lines changed

.github/workflows/test.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Set up Go
1818
uses: actions/setup-go@v5
1919
with:
20-
go-version: "1.23"
20+
go-version-file: go.mod
2121

2222
- name: Install dependencies
2323
run: go mod tidy
@@ -28,11 +28,17 @@ jobs:
2828
- name: Run tests
2929
run: go test ./... -v
3030

31+
- name: golangci-lint
32+
uses: golangci/golangci-lint-action@v7
33+
with:
34+
version: v2.1
35+
args: --issues-exit-code=1 --timeout 5m
36+
only-new-issues: false
37+
3138
- name: Run tests with coverage
3239
run: go test -coverprofile=coverage.txt
3340

3441
- name: Upload results to Codecov
3542
uses: codecov/codecov-action@v5
3643
env:
3744
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
38-

.golangci.yml

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
version: "2"
2+
3+
linters:
4+
default: all
5+
disable:
6+
# redundant
7+
- cyclop # revive
8+
- funlen # revive
9+
- gocognit # revive
10+
- gocyclo # revive
11+
- lll # revive
12+
- unparam # revive
13+
14+
# too strict
15+
- depguard
16+
- exhaustive
17+
- exhaustruct
18+
- gochecknoglobals
19+
- godot
20+
- mnd
21+
- paralleltest
22+
- testpackage
23+
- varnamelen
24+
25+
# strict formatting
26+
- nlreturn
27+
- whitespace
28+
- wsl
29+
30+
# nice to have
31+
- usetesting
32+
- unused
33+
- testifylint
34+
- perfsprint
35+
36+
settings:
37+
38+
errcheck:
39+
check-type-assertions: true
40+
41+
gocritic:
42+
enable-all: true
43+
disabled-checks:
44+
- unnamedResult
45+
- sloppyLen
46+
- singleCaseSwitch
47+
48+
govet:
49+
disable:
50+
- fieldalignment
51+
enable-all: true
52+
53+
maintidx:
54+
# higher = better
55+
under: 20
56+
57+
misspell:
58+
locale: US
59+
60+
nestif:
61+
# lower=better
62+
min-complexity: 5
63+
64+
# nlreturn:
65+
# block-size: 5
66+
67+
nolintlint:
68+
require-explanation: false # don't require an explanation for nolint directives
69+
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
70+
allow-unused: false # report any unused nolint directives
71+
72+
revive:
73+
severity: error
74+
enable-all-rules: true
75+
rules:
76+
- name: add-constant
77+
disabled: true
78+
- name: cognitive-complexity
79+
arguments:
80+
- 38
81+
- name: cyclomatic
82+
arguments:
83+
# lower=better
84+
- 32
85+
- name: empty-lines
86+
disabled: true
87+
- name: function-length
88+
arguments:
89+
# statements
90+
- 81
91+
# lines
92+
- 123
93+
- name: line-length-limit
94+
arguments:
95+
- 160
96+
- name: max-control-nesting
97+
arguments:
98+
# lower=better
99+
- 3
100+
- name: max-public-structs
101+
disabled: true
102+
- name: indent-error-flow
103+
disabled: true
104+
- name: package-comments
105+
disabled: true
106+
- name: unnecessary-stmt
107+
disabled: true
108+
- name: unused-parameter
109+
disabled: true
110+
- name: unused-receiver
111+
disabled: true
112+
113+
staticcheck:
114+
checks:
115+
- all
116+
- -ST1000
117+
118+
wsl:
119+
allow-trailing-comment: true
120+
121+
exclusions:
122+
presets:
123+
- common-false-positives
124+
- legacy
125+
- std-error-handling
126+
127+
issues:
128+
max-issues-per-linter: 0
129+
max-same-issues: 0
130+
131+
formatters:
132+
settings:
133+
gci:
134+
sections:
135+
- standard
136+
- default
137+
- prefix(github.com/goforj/godump)
138+
139+
exclusions:
140+
paths:
141+
- third_party$
142+
- builtin$
143+
- examples$

go.mod

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
module github.com/goforj/godump
22

3-
go 1.23.1
3+
go 1.23
4+
5+
require github.com/stretchr/testify v1.10.0
46

57
require (
68
github.com/davecgh/go-spew v1.1.1 // indirect
79
github.com/pmezard/go-difflib v1.0.0 // indirect
8-
github.com/stretchr/testify v1.10.0 // indirect
910
gopkg.in/yaml.v3 v3.0.1 // indirect
1011
)

go.sum

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
44
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
55
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
66
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
7+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
78
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
89
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
910
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 commit comments

Comments
 (0)