Skip to content

Intermittent errors when re-running linters (eventually succeeding, seems to be cache-related) #5437

@vegas503

Description

@vegas503

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?

Docker

Description of the problem

When running inside Docker, errors that are reported are changing among runs, eventually reducing to zero.

Initial errors are somewhat absurd: first it reports names that are clearly known as unknown, then it throws some errors about "no export data", then it finally succeeds. Re-running in new container from scratch reproduces the problem over and over.

Sometimes (very rarely) the check succeeds at first try.

Example:

$ docker run --rm -it -v $PWD:/code --entrypoint sh golangci/golangci-lint:v1.64.5-alpine
$ cd /code/master/
$ golangci-lint run
internal/infrastructure/database/database.go:85:14: a.Transaction undefined (type *Adapter has no field or method Transaction) (typecheck)
        if err := a.Transaction(func(tx *gorm.DB) error {
                    ^
pkg/auth/jwt2.go:83:29: claims.Audience undefined (type *Claims has no field or method Audience) (typecheck)
        for _, aud := range claims.Audience {
                                   ^
pkg/auth/jwt2.go:87:30: claims.Subject undefined (type *Claims has no field or method Subject) (typecheck)
        return j.GenerateJWT(claims.Subject, claims.Name, audiences, ttl)
                                    ^
pkg/auth/jwt2.go:131:40: claims.Subject undefined (type *Claims has no field or method Subject) (typecheck)
        subjectUUID, err := uuid.Parse(claims.Subject)
                                              ^
$ golangci-lint cache status
Dir: /root/.cache/golangci-lint
Size: 453.3KiB
$ golangci-lint run
internal/infrastructure/database/database.go:85:14: a.Transaction undefined (type *Adapter has no field or method Transaction) (typecheck)
        if err := a.Transaction(func(tx *gorm.DB) error {
                    ^
pkg/auth/jwt2.go:83:29: claims.Audience undefined (type *Claims has no field or method Audience) (typecheck)
        for _, aud := range claims.Audience {
                                   ^
pkg/auth/jwt2.go:87:30: claims.Subject undefined (type *Claims has no field or method Subject) (typecheck)
        return j.GenerateJWT(claims.Subject, claims.Name, audiences, ttl)
                                    ^
pkg/auth/jwt2.go:131:40: claims.Subject undefined (type *Claims has no field or method Subject) (typecheck)
        subjectUUID, err := uuid.Parse(claims.Subject)
                                              ^
$ golangci-lint cache status
Dir: /root/.cache/golangci-lint
Size: 461.4KiB
$ golangci-lint run
internal/infrastructure/database/database.go:85:14: a.Transaction undefined (type *Adapter has no field or method Transaction) (typecheck)
        if err := a.Transaction(func(tx *gorm.DB) error {
                    ^
$ golangci-lint cache status
Dir: /root/.cache/golangci-lint
Size: 465.4KiB
$ golangci-lint run
internal/infrastructure/database/database.go:85:14: a.Transaction undefined (type *Adapter has no field or method Transaction) (typecheck)
        if err := a.Transaction(func(tx *gorm.DB) error {
                    ^
$ golangci-lint run
internal/infrastructure/database/database.go:85:14: a.Transaction undefined (type *Adapter has no field or method Transaction) (typecheck)
        if err := a.Transaction(func(tx *gorm.DB) error {
                    ^
$ golangci-lint cache status
Dir: /root/.cache/golangci-lint
Size: 488.5KiB
$ golangci-lint run
internal/infrastructure/database/database.go:85:14: a.Transaction undefined (type *Adapter has no field or method Transaction) (typecheck)
        if err := a.Transaction(func(tx *gorm.DB) error {
                    ^
$ golangci-lint run
internal/infrastructure/database/database.go:85:14: a.Transaction undefined (type *Adapter has no field or method Transaction) (typecheck)
        if err := a.Transaction(func(tx *gorm.DB) error {
                    ^
$ golangci-lint run
internal/infrastructure/database/database.go:85:14: a.Transaction undefined (type *Adapter has no field or method Transaction) (typecheck)
        if err := a.Transaction(func(tx *gorm.DB) error {
                    ^
$ golangci-lint run
WARN [runner] Can't run linter goanalysis_metalinter: buildssa: failed to load package : could not load export data: no export data for "golang.org/x/crypto/argon2"
ERRO Running error: can't run linter goanalysis_metalinter
buildssa: failed to load package : could not load export data: no export data for "golang.org/x/crypto/argon2"
$ golangci-lint run
WARN [runner] Can't run linter goanalysis_metalinter: buildssa: failed to load package : could not load export data: no export data for "github.com/sirupsen/logrus"
ERRO Running error: can't run linter goanalysis_metalinter
buildssa: failed to load package : could not load export data: no export data for "github.com/sirupsen/logrus"
$ golangci-lint run
$ golangci-lint run
$

Version of golangci-lint

golangci-lint has version 1.64.5 built with go1.24.0 from 0a603e49 on 2025-02-13T21:19:55Z

Configuration

linters:
  enable:
    - wsl
    - wrapcheck
    - nlreturn
    - revive
    - noctx
    - gocritic
    - errorlint
    - forcetypeassert
  disable:
    - gosec
    - errchkjson
  presets:
    - bugs

Go environment

go version go1.24.0 linux/amd64
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='/root/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/root/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2166277634=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/dev/null'
GOMODCACHE='/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/root/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.24.0'
GOWORK=''
PKG_CONFIG='pkg-config'

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
INFO golangci-lint has version 1.64.5 built with go1.24.0 from 0a603e49 on 2025-02-13T21:19:55Z
INFO [config_reader] Config search paths: [./ /code/master /code / /root]
INFO [config_reader] Used config file .golangci.yml
INFO [lintersdb] Active 34 linters: [asasalint asciicheck bidichk bodyclose contextcheck durationcheck errcheck errorlint exhaustive forcetypeassert gocheckcompilerdirectives gochecksumtype gocritic gosmopolitan govet loggercheck makezero musttag nilerr nilnesserr nlreturn noctx protogetter reassign recvcheck revive rowserrcheck spancheck sqlclosecheck staticcheck testifylint wrapcheck wsl zerologlint]
INFO [lintersdb] Active presets: [bugs]
INFO [loader] Go packages loading at mode 8767 (compiled_files|deps|name|exports_file|files|imports|types_sizes) took 4.104754493s
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 2.032563ms
INFO [linters_context/goanalysis] analyzers took 6.082579498s with top 10 stages: buildir: 2.476874341s, the_only_name: 878.162677ms, buildssa: 841.389473ms, exhaustive: 359.195026ms, inspect: 127.562201ms, ctrlflow: 105.711464ms, printf: 92.734232ms, fact_deprecated: 91.817172ms, fact_purity: 77.438145ms, SA5012: 70.286243ms
INFO [runner] Issues before processing: 677, after processing: 4
INFO [runner] Processors filtering stat (in/out): sort_results: 4/4, filename_unadjuster: 677/677, invalid_issue: 677/664, exclude-rules: 664/664, uniq_by_line: 664/4, diff: 4/4, max_per_file_from_linter: 4/4, fixer: 4/4, path_prefixer: 4/4, path_prettifier: 664/664, skip_dirs: 664/664, identifier_marker: 664/664, exclude: 664/664, cgo: 677/677, autogenerated_exclude: 664/664, max_same_issues: 4/4, severity-rules: 4/4, path_shortener: 4/4, skip_files: 664/664, nolint: 664/664, max_from_linter: 4/4, source_code: 4/4
INFO [runner] processing took 4.891142ms with stages: identifier_marker: 4.450441ms, path_prettifier: 117.264µs, cgo: 36.931µs, filename_unadjuster: 36.611µs, uniq_by_line: 35.938µs, autogenerated_exclude: 35.902µs, nolint: 35.545µs, exclude-rules: 35.485µs, invalid_issue: 34.69µs, skip_dirs: 33.884µs, source_code: 32.496µs, max_from_linter: 2.834µs, max_same_issues: 1.187µs, path_shortener: 578ns, max_per_file_from_linter: 552ns, sort_results: 170ns, skip_files: 162ns, fixer: 160ns, exclude: 133ns, diff: 78ns, path_prefixer: 52ns, severity-rules: 49ns
INFO [runner] linters took 1.80729994s with stages: goanalysis_metalinter: 1.80236229s
internal/infrastructure/database/database.go:85:14: a.Transaction undefined (type *Adapter has no field or method Transaction) (typecheck)
        if err := a.Transaction(func(tx *gorm.DB) error {
                    ^
pkg/auth/jwt2.go:83:29: claims.Audience undefined (type *Claims has no field or method Audience) (typecheck)
        for _, aud := range claims.Audience {
                                   ^
pkg/auth/jwt2.go:87:30: claims.Subject undefined (type *Claims has no field or method Subject) (typecheck)
        return j.GenerateJWT(claims.Subject, claims.Name, audiences, ttl)
                                    ^
pkg/auth/jwt2.go:131:40: claims.Subject undefined (type *Claims has no field or method Subject) (typecheck)
        subjectUUID, err := uuid.Parse(claims.Subject)
                                              ^
INFO File cache stats: 2 entries of total size 6.6KiB
INFO Memory: 61 samples, avg is 111.6MB, max is 428.7MB
INFO Execution took 5.916780985s
$

NOTE: Sometimes the above errors are printed, and sometimes they are not and the check runs successfully.

A minimal reproducible example or link to a public repository

Unable to provide due to private codebase, furthermore the issue seems to be unrelated to project's code.

Validation

  • Yes, I've included all information above (version, config, etc.).

Supporter

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions