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

View file

@ -196,7 +196,7 @@ func (app *restServerApp) runRoot(_ *cobra.Command, _ []string) error {
case "1.3":
tlscfg.MinVersion = tls.VersionTLS13
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{