-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Welcome
- Yes, I'm using a binary release within 2 latest releases. Only such installations are supported.
- Yes, I've searched similar issues on GitHub and didn't find any.
- Yes, I've read the
typecheck
section of the FAQ. - Yes, I've tried with the standalone linter if available (e.g., gocritic, go vet, etc.).
- I agree to follow this project's Code of Conduct
How did you install golangci-lint?
Official GitHub Action
Description of the problem
In our repo (https://github.com/opencontainers/runc) we use golangci-lint action, and from time to time I see false positives like this:
Error: libcontainer/capabilities/capabilities_linux_test.go:53:5: SA5011(related information): this check suggests that the pointer can be nil (staticcheck)
if l == nil {
^
Error: libcontainer/capabilities/capabilities_linux_test.go:56:7: SA5011: possible nil pointer dereference (staticcheck)
if l.Level != expectedLogs.Level {
^
Error: libcontainer/configs/tocpuset_test.go:81:7: SA5011(related information): this check suggests that the pointer can be nil (staticcheck)
if out == nil {
^
Error: libcontainer/configs/tocpuset_test.go:84:7: SA5011: possible nil pointer dereference (staticcheck)
if *out != *tc.out {
^
Error: libcontainer/system/kernelversion/kernel_linux_test.go:32:5: SA5011(related information): this check suggests that the pointer can be nil (staticcheck)
if version == nil {
^
Error: libcontainer/system/kernelversion/kernel_linux_test.go:35:13: SA5011: possible nil pointer dereference (staticcheck)
if version.Kernel == 0 {
^
6 issues:
* staticcheck: 6
In all 3 cases, the code looks like this:
if l == nil {
t.Fatal("expected a warning, but got none")
}
if l.Level != expectedLogs.Level {
t.Errorf("expected %q, got %q", expectedLogs.Level, l.Level)
}
NOTE
- this does not happens always, but occasionally, from time to time;
- re-running the same job does not help;
- clearing golangci-cache always helps.
My gut feeling this is something related to the cache.
Here is a run which uses cache (with false positives): https://github.com/opencontainers/runc/actions/runs/16771007365/job/47485871649
Here's a second run (no changes): https://github.com/opencontainers/runc/actions/runs/16771007365/job/47536430979
Here's a third run, with the cache (golangci-lint.cache-Linux-2900-07b6deaeaf77c89136c312b904939c6615b804c9') manually removed, (no more false positives): https://github.com/opencontainers/runc/actions/runs/16771007365/job/47536777801
What puzzles me is the last job still says:
Cache hit for: golangci-lint.cache-Linux-2900-07b6deaeaf77c89136c312b904939c6615b804c9
Received 641357 of 641357 (100.0%), 9.7 MBs/sec
Cache Size: ~1 MB (641357 B)
/usr/bin/tar -xf /home/runner/work/_temp/f540f2d7-e2d1-4b51-9da4-0209e70389ca/cache.tzst -P -C /home/runner/work/runc/runc --use-compress-program unzstd
Cache restored successfully
Restored cache for golangci-lint from key 'golangci-lint.cache-Linux-2900-07b6deaeaf77c89136c312b904939c6615b804c9' in 404ms
although I manually removed this very cache just before re-running the job, so something might be wrong in github actions department, too.
Version of golangci-lint
From the gha log:
Finding needed golangci-lint version...
Requested golangci-lint 'v2.3', using 'v2.3.1', calculation took 56ms
Installation mode: binary
Installing golangci-lint binary v2.3.1...
Downloading binary https://github.com/golangci/golangci-lint/releases/download/v2.3.1/golangci-lint-2.3.1-linux-amd64.tar.gz ...
/usr/bin/tar xz --overwrite --warning=no-unknown-keyword --overwrite -C /home/runner -f /home/runner/work/_temp/f2018b3e-500b-44ad-a3d6-5109026baf62
Installed golangci-lint into /home/runner/golangci-lint-2.3.1-linux-amd64/golangci-lint in 435ms
Prepared env in 896ms
Configuration
See https://github.com/opencontainers/runc/blob/127e8e68d335aa7b908c7822fa985629d8fbe81d/.golangci.yml
Go environment
From the job logs:
Run actions/setup-go@v5
with:
go-version: 1.24
check-latest: false
token: ***
cache: true
env:
GO_VERSION: 1.24
Setup go version spec 1.24
Found in cache @ /opt/hostedtoolcache/go/1.24.5/x64
Added go to the path
Successfully set up Go version 1.24
/opt/hostedtoolcache/go/1.24.5/x64/bin/go env GOMODCACHE
/opt/hostedtoolcache/go/1.24.5/x64/bin/go env GOCACHE
/home/runner/go/pkg/mod
/home/runner/.cache/go-build
Cache hit for: setup-go-Linux-x64-ubuntu24-go-1.24.5-2a435ec440cb466e7517b049c14e40c85fd4691bea511023e036a40f9c346cf3
Received 18690705 of 18690705 (100.0%), 87.4 MBs/sec
Cache Size: ~18 MB (18690705 B)
/usr/bin/tar -xf /home/runner/work/_temp/1a117bb1-dab9-4a76-899d-e2661d1695d1/cache.tzst -P -C /home/runner/work/runc/runc --use-compress-program unzstd
Cache restored successfully
Cache restored from key: setup-go-Linux-x64-ubuntu24-go-1.24.5-2a435ec440cb466e7517b049c14e40c85fd4691bea511023e036a40f9c346cf3
go version go1.24.5 linux/amd64
go env
AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/runner/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/runner/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build444757353=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/runner/work/runc/runc/go.mod'
GOMODCACHE='/home/runner/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/runner/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct/'
GOROOT='/opt/hostedtoolcache/go/1.24.5/x64'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/runner/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/hostedtoolcache/go/1.24.5/x64/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.24.5'
GOWORK=''
PKG_CONFIG='pkg-config'
Verbose output of running
I can't reproduce it locally.
A minimal reproducible example or link to a public repository
See above.
Validation
- Yes, I've included all information above (version, config, etc.).
Supporter
- I am a sponsor/backer through GitHub or OpenCollective