Skip to content

Commit d088706

Browse files
committed
Add lint
1 parent ffb311d commit d088706

File tree

4 files changed

+50
-3
lines changed

4 files changed

+50
-3
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,10 @@ jobs:
2929
with:
3030
go-version: '^1.18.4'
3131
cache: true
32+
- name: golangci-lint
33+
uses: golangci/golangci-lint-action@v3
34+
with:
35+
version: 1.48.0
36+
skip-pkg-cache: true
37+
skip-build-cache: true
3238
- run: go run mage.go test

.golangci.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
linters:
2+
enable:
3+
- asasalint
4+
- bidichk
5+
- bodyclose
6+
- decorder
7+
- durationcheck
8+
- errchkjson
9+
- errname
10+
- errorlint
11+
- execinquery
12+
- exhaustive
13+
- exportloopref
14+
- gocritic
15+
- goerr113
16+
- gofmt
17+
- goimports
18+
- goprintffuncname
19+
- gosec
20+
- importas
21+
- misspell
22+
- nolintlint
23+
- nosnakecase
24+
- prealloc
25+
- predeclared
26+
- promlinter
27+
- revive
28+
- stylecheck
29+
- tagliatelle
30+
- tenv
31+
- thelper
32+
- unconvert
33+
- usestdlibvars
34+
issues:
35+
exclude-rules:
36+
- path: magefiles/
37+
linters:
38+
- deadcode

magefiles/magefile.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import (
66
"github.com/magefile/mage/sh"
77
)
88

9-
var gosImports = sh.RunCmd("go", "run", fmt.Sprintf("github.com/rinchsan/gosimports/cmd/gosimports@%s", gosImportsVer))
10-
119
func Build() error {
1210
return sh.Run("go", "build", "-o", "build/reassign", "./cmd")
1311
}
@@ -17,7 +15,11 @@ func Test() error {
1715
}
1816

1917
func Format() error {
20-
return gosImports("-w", ".")
18+
return sh.RunV("go", "run", fmt.Sprintf("github.com/rinchsan/gosimports/cmd/gosimports@%s", gosImportsVer), "-w", ".")
19+
}
20+
21+
func Check() error {
22+
return sh.RunV("go", "run", fmt.Sprintf("github.com/golangci/golangci-lint/cmd/golangci-lint@%s", golangCILintVer), "run")
2123
}
2224

2325
var Default = Build

magefiles/versions.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
package main
22

3+
var golangCILintVer = "v1.48.0"
34
var gosImportsVer = "v0.1.5"

0 commit comments

Comments
 (0)