migrate to golangci-lint v2

This commit is contained in:
Michael Eischer 2025-12-06 20:16:26 +01:00
parent b3ce796ae7
commit 512d7e88ee
3 changed files with 33 additions and 45 deletions

View file

@ -86,10 +86,10 @@ jobs:
go-version: ${{ env.latest_go }} go-version: ${{ env.latest_go }}
- name: golangci-lint - name: golangci-lint
uses: golangci/golangci-lint-action@v6 uses: golangci/golangci-lint-action@v9
with: with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.64.8 version: v2.4.0
args: --verbose --timeout 5m args: --verbose --timeout 5m
# only run golangci-lint for pull requests, otherwise ALL hints get # only run golangci-lint for pull requests, otherwise ALL hints get

View file

@ -1,56 +1,44 @@
# This is the configuration for golangci-lint for the restic project. version: "2"
#
# A sample config with all settings is here:
# https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml
linters: linters:
# only enable the linters listed below # only enable the linters listed below
disable-all: true default: none
enable: enable:
# ensure that http response bodies are closed
- bodyclose
# make sure all errors returned by functions are handled # make sure all errors returned by functions are handled
- errcheck - errcheck
# show how code can be simplified
- gosimple
# make sure code is formatted
- gofmt
# examine code and report suspicious constructs, such as Printf calls whose # examine code and report suspicious constructs, such as Printf calls whose
# arguments do not align with the format string # arguments do not align with the format string
- govet - govet
# consistent imports
# make sure names and comments are used according to the conventions - importas
- revive
# detect when assignments to existing variables are not used # detect when assignments to existing variables are not used
- ineffassign - ineffassign
# make sure names and comments are used according to the conventions
- revive
# run static analysis and find errors # run static analysis and find errors
- staticcheck - staticcheck
# find unused variables, functions, structs, types, etc. # find unused variables, functions, structs, types, etc.
- unused - unused
exclusions:
# parse and typecheck code rules:
- typecheck - path: (.+)\.go$
text: exported (function|method|var|type|const) .* should have comment or be unexported
# ensure that http response bodies are closed - path: (.+)\.go$
- bodyclose text: don't use ALL_CAPS in Go names; use CamelCase
- path: (.+)\.go$
- importas text: "package-comments: should have a package comment"
- path: (.+)\.go$
issues: text: "redefines-builtin-id:"
# don't use the default exclude rules, this hides (among others) ignored paths:
# errors from Close() calls - third_party$
exclude-use-default: false - builtin$
- examples$
# list of things to not warn about formatters:
exclude: enable:
# revive: do not warn about missing comments for exported stuff - gofmt
- exported (function|method|var|type|const) .* should have comment or be unexported exclusions:
# revive: ignore constants in all caps paths:
- don't use ALL_CAPS in Go names; use CamelCase - third_party$
# revive: lots of packages don't have such a comment - builtin$
- "package-comments: should have a package comment" - examples$
- "redefines-builtin-id:"

View file

@ -196,7 +196,7 @@ func (app *restServerApp) runRoot(_ *cobra.Command, _ []string) error {
case "1.3": case "1.3":
tlscfg.MinVersion = tls.VersionTLS13 tlscfg.MinVersion = tls.VersionTLS13
default: default:
return fmt.Errorf("Unsupported TLS min version: %s. Allowed versions are 1.2 or 1.3", app.Server.TLSMinVer) return fmt.Errorf("unsupported TLS min version: %s. Allowed versions are 1.2 or 1.3", app.Server.TLSMinVer)
} }
srv := &http.Server{ srv := &http.Server{