Skip to content

Commit c325233

Browse files
committed
build: Update golangci-lint to v2.4.0.
This updates golangci-lint to v2.4.0 and adds an appropriate configuration file. It also adds several new linters and updates the script used to run tests and linters accordingly.
1 parent e94d917 commit c325233

3 files changed

Lines changed: 41 additions & 24 deletions

File tree

.github/workflows/go.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
with:
1616
go-version: ${{ matrix.go }}
1717
- name: Install Linters
18-
run: "curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.52.2"
18+
run: "go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.4.0"
1919
- name: Test
2020
run: |
2121
sh ./run_tests.sh

.golangci.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
version: "2"
2+
run:
3+
timeout: 10m
4+
linters:
5+
default: none
6+
enable:
7+
- asciicheck
8+
- bidichk
9+
- bodyclose
10+
- dupword
11+
- durationcheck
12+
- errcheck
13+
- errorlint
14+
- govet
15+
- grouper
16+
- ineffassign
17+
- misspell
18+
- nilerr
19+
- nosprintfhostport
20+
- paralleltest
21+
- reassign
22+
- rowserrcheck
23+
- staticcheck
24+
- tparallel
25+
- unconvert
26+
- unused
27+
- usetesting
28+
settings:
29+
staticcheck:
30+
checks:
31+
- S1*
32+
formatters:
33+
enable:
34+
- gofmt
35+
- goimports

run_tests.sh

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,12 @@
22

33
set -ex
44

5-
# The script does automatic checking on a Go package and its sub-packages, including:
6-
# 1. race detector (http://blog.golang.org/race-detector)
7-
# 2. gofmt (http://golang.org/cmd/gofmt/)
8-
# 3. golint (https://github.com/golang/lint)
9-
# 4. go vet (http://golang.org/cmd/vet)
10-
# 5. gosimple (https://github.com/dominikh/go-simple)
11-
# 6. unconvert (https://github.com/mdempsky/unconvert)
12-
# 7. ineffassign (https://github.com/gordonklaus/ineffassign)
13-
# 8. misspell (https://github.com/client9/misspell)
14-
# 9. deadcode (https://github.com/remyoudompheng/go-misc/tree/master/deadcode)
5+
# This script runs the tests for all packages in the repository and then uses
6+
# golangci-lint (github.com/golangci/golangci-lint) to run all linters defined
7+
# by the configuration in .golangci.yml.
158

169
# run tests
1710
env GORACE="halt_on_error=1" go test -race ./...
1811

19-
# golangci-lint (github.com/golangci/golangci-lint) is used to run each each
20-
# static checker.
21-
22-
# check linters
23-
golangci-lint run --disable-all --deadline=10m \
24-
--enable=gofmt \
25-
--enable=revive \
26-
--enable=vet \
27-
--enable=gosimple \
28-
--enable=unconvert \
29-
--enable=ineffassign \
30-
--enable=misspell \
31-
--enable=deadcode
12+
# run linters
13+
golangci-lint run

0 commit comments

Comments
 (0)