Skip to content

Commit

Permalink
ci: standardize Go setup and linting configuration
Browse files Browse the repository at this point in the history
- Rename "Checkout repository" step to "Checkout"
- Rename "Setup go" step to "Set up Go"
- Change Go version specification to "^1"
- Add version specification for golangci-lint setup
- Add a new `.golangci.yaml` configuration file with various linter settings and rules

Signed-off-by: appleboy <appleboy.tw@gmail.com>
  • Loading branch information
appleboy committed Nov 15, 2024
1 parent 93a38b5 commit 77286bb
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 5 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,18 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup go
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
check-latest: true
go-version: "^1"
- name: Setup golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.61.0
args: --verbose
test:
strategy:
Expand Down
72 changes: 72 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
run:
timeout: 5m
linters:
enable:
- asciicheck
- dogsled
- durationcheck
- errcheck
- errorlint
- exportloopref
- gci
- gofmt
- goimports
- gosec
- misspell
- nakedret
- nilerr
- nolintlint
- perfsprint
- revive
- testifylint
- usestdlibvars
- wastedassign

linters-settings:
gosec:
# To select a subset of rules to run.
# Available rules: https://github.com/securego/gosec#available-rules
# Default: [] - means include all rules
includes:
- G102
- G106
- G108
- G109
- G111
- G112
- G201
- G203
perfsprint:
err-error: true
errorf: true
fiximports: true
int-conversion: true
sprintf1: true
strconcat: true
testifylint:
enable-all: true

issues:
exclude-rules:
- linters:
- structcheck
- unused
text: "`data` is unused"
- linters:
- staticcheck
text: "SA1019:"
- linters:
- revive
text: "var-naming:"
- linters:
- revive
text: "exported:"
- path: _test\.go
linters:
- gosec # security is not make sense in tests
- linters:
- revive
path: _test\.go
- path: gin.go
linters:
- gci

0 comments on commit 77286bb

Please sign in to comment.