ci: revise golangci-lint configuration and update versioning

- Update golangci-lint-action used version from `v6` to `v7`
- Set specific golangci-lint version to `v2.0` instead of latest
- Remove `run` section with timeout setting in `.golangci.yaml`
- Eliminate multiple linters (`errcheck`, `gci`, `gofmt`, `goimports`) from `.golangci.yaml`
- Change `linters-settings` to `settings` in `.golangci.yaml`
- Add `int-conversion: true` to `perfsprint` settings
- Add new exclusion settings for generated code, preset rules, and specific paths under `exclusions` in `.golangci.yaml`
- Incorporate formatter settings with enabled formatters and exclusions for certain paths in `.golangci.yaml`

Signed-off-by: appleboy <appleboy.tw@gmail.com>
This commit is contained in:
appleboy
2025-04-11 23:35:39 +08:00
parent 2173b97920
commit 691536f46b
2 changed files with 42 additions and 29 deletions
+2 -2
View File
@@ -15,9 +15,9 @@ jobs:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Setup golangci-lint - name: Setup golangci-lint
uses: golangci/golangci-lint-action@v6 uses: golangci/golangci-lint-action@v7
with: with:
version: latest version: v2.0
args: --verbose args: --verbose
- uses: hadolint/hadolint-action@v3.1.0 - uses: hadolint/hadolint-action@v3.1.0
+40 -27
View File
@@ -1,14 +1,9 @@
run: version: "2"
timeout: 5m
linters: linters:
enable: enable:
- asciicheck - asciicheck
- durationcheck - durationcheck
- errcheck
- errorlint - errorlint
- gci
- gofmt
- goimports
- gosec - gosec
- misspell - misspell
- nakedret - nakedret
@@ -18,24 +13,42 @@ linters:
- revive - revive
- usestdlibvars - usestdlibvars
- wastedassign - wastedassign
settings:
linters-settings: gosec:
gosec: includes:
# To select a subset of rules to run. - G102
# Available rules: https://github.com/securego/gosec#available-rules - G106
# Default: [] - means include all rules - G108
includes: - G109
- G102 - G111
- G106 - G112
- G108 - G201
- G109 - G203
- G111 perfsprint:
- G112 int-conversion: true
- G201 err-error: true
- G203 errorf: true
perfsprint: sprintf1: true
err-error: true strconcat: true
errorf: true exclusions:
int-conversion: true generated: lax
sprintf1: true presets:
strconcat: true - comments
- common-false-positives
- legacy
- std-error-handling
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gci
- gofmt
- goimports
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$