Bump golangci-lint for go1.25

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
This commit is contained in:
Brad Davidson 2025-12-12 01:06:39 +00:00 committed by Brad Davidson
parent 54b792e6d5
commit 2d313a6f72
5 changed files with 59 additions and 57 deletions

View file

@ -1,46 +0,0 @@
{
"linters": {
"disable-all": true,
"enable": [
"govet",
"revive",
"goimports",
"misspell",
"gofmt"
]
},
"run": {
"deadline": "5m"
},
"issues": {
"exclude-dirs": [
"build",
"contrib",
"manifests",
"package",
"scripts",
"vendor"
],
"exclude-files": [
"/zz_generated_"
],
"exclude-rules": [
{
"linters": "typecheck",
"text": "imported but not used"
},
{
"linters": "typecheck",
"text": "build constraints exclude all Go files"
},
{
"linters": "revive",
"text": "should have comment"
},
{
"linters": "revive",
"text": "exported"
}
]
}
}

50
.golangci.yml Normal file
View file

@ -0,0 +1,50 @@
formatters:
enable:
- gofmt
- goimports
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
linters:
default: none
enable:
- govet
- revive
settings:
revive:
enable-all-rules: true
rules:
- {name: add-constant, disabled: true}
- {name: cognitive-complexity, disabled: true}
- {name: confusing-naming, disabled: true}
- {name: confusing-results, disabled: true}
- {name: cyclomatic, disabled: true}
- {name: early-return, disabled: true}
- {name: enforce-switch-style, disabled: true}
- {name: flag-parameter, disabled: true}
- {name: function-length, disabled: true}
- {name: function-result-limit, disabled: true}
- {name: import-shadowing, disabled: true}
- {name: line-length-limit, disabled: true}
- {name: redundant-import-alias, disabled: true}
- {name: max-control-nesting, disabled: true}
- {name: max-public-structs, disabled: true}
- {name: unused-parameter, disabled: true}
- {name: unused-receiver, disabled: true}
- {name: var-naming, disabled: true}
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
- tests/
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
version: "2"

View file

@ -28,14 +28,14 @@ RUN case "$(go env GOARCH)" in \
fi
# Install goimports
RUN GOPROXY=direct go install golang.org/x/tools/cmd/goimports@gopls/v0.16.0
RUN GOPROXY=direct go install golang.org/x/tools/cmd/goimports@gopls/v0.20.0
# Cleanup
RUN rm -rf /go/src /go/pkg
# Install golangci-lint for amd64
RUN if [ "$(go env GOARCH)" = "amd64" ]; then \
curl -sL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.55.2; \
curl -sL https://raw.githubusercontent.com/golangci/golangci-lint/refs/tags/v2.7.2/install.sh | sh -s -- v2.7.2; \
fi
# Set SELINUX environment variable

View file

@ -11,11 +11,11 @@ RUN apk -U --no-cache add bash git gcc musl-dev docker vim less file curl wget c
fi
# Install goimports
RUN GOPROXY=direct go install golang.org/x/tools/cmd/goimports@gopls/v0.16.0
RUN GOPROXY=direct go install golang.org/x/tools/cmd/goimports@gopls/v0.20.0
RUN rm -rf /go/src /go/pkg
RUN if [ "$(go env GOARCH)" = "amd64" ]; then \
curl -sL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.51.2; \
curl -sL https://raw.githubusercontent.com/golangci/golangci-lint/refs/tags/v2.7.2/install.sh | sh -s -- v2.7.2; \
fi
ARG SELINUX=true

View file

@ -1,6 +1,8 @@
#!/bin/bash
set -e
export GIT_PAGER=cat
if [ -n "$SKIP_VALIDATE" ]; then
echo Skipping validation
exit
@ -38,11 +40,7 @@ if [ ! -e build/data ];then
mkdir -p build/data
fi
if ! command -v golangci-lint; then
echo Skipping validation: no golangci-lint available
exit
if [ -z "$SKIP_LINT" ] && command -v golangci-lint; then
echo Running: golangci-lint
golangci-lint run --timeout=5m
fi
#echo Running: golangci-lint
## https://github.com/golangci/golangci-lint/issues/2788
#CGO_ENABLED=0 golangci-lint run -v