-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Labels
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
typechecksection 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?
go install
Description of the problem
It seems the cache is not invalidated when a source file that is excluded from the build on the current platform is modified. This can lead to "ghost" issues being reported from linters on said files after they are fixed, or issues being missed.
See minimal example below.
Could be related to the use of CompiledGoFiles (as opposed to GoFiles) when constructing the hash here?
Version of golangci-lint
$ golangci-lint --version
golangci-lint has version 2.6.1 built with go1.25.0 from (e3b3bac5dd24906c205db9224fde52efd4d238cf, modified: false, mod sum: "") on 2025-11-04T10:58:22ZConfiguration
linters:
enable:
- govetGo environment
go version go1.25.0 linux/amd64Verbose output of running
INFO golangci-lint has version 2.6.1 built with go1.25.0 from (e3b3bac5dd24906c205db9224fde52efd4d238cf, modified: false, mod sum: "") on 2025-11-04T10:58:22Z
INFO [config_reader] Config search paths: [./ /home/miles/repos/example /home/miles/repos /home/miles /home /]
INFO [config_reader] Used config file .golangci.yml
INFO [config_reader] Module name "example.com/mod"
INFO maxprocs: Leaving GOMAXPROCS=28: CPU quota undefined
INFO [goenv] Read go env for 6.824869ms: map[string]string{"GOCACHE":"/home/miles/.cache/go-build", "GOROOT":"/home/miles/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.25.0.linux-amd64"}
INFO [lintersdb] Active 5 linters: [errcheck govet ineffassign staticcheck unused]
INFO [loader] Go packages loading at mode 8767 (types_sizes|compiled_files|imports|deps|exports_file|files|name) took 42.059555ms
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 72.382µs
INFO [linters_context/goanalysis] analyzers took 0s with no stages
INFO [runner] processing took 1.716µs with stages: max_same_issues: 426ns, exclusion_paths: 253ns, path_absoluter: 119ns, exclusion_rules: 115ns, source_code: 95ns, diff: 91ns, path_shortener: 87ns, path_prettifier: 80ns, max_from_linter: 62ns, nolint_filter: 58ns, severity-rules: 46ns, filename_unadjuster: 34ns, invalid_issue: 33ns, generated_file_filter: 32ns, path_relativity: 31ns, sort_results: 31ns, fixer: 31ns, max_per_file_from_linter: 31ns, uniq_by_line: 31ns, cgo: 30ns
INFO [runner] linters took 281.033µs with stages: goanalysis_metalinter: 263.108µs
0 issues.
INFO File cache stats: 0 entries of total size 0B
INFO Memory: 2 samples, avg is 37.6MB, max is 39.6MB
INFO Execution took 49.634323ms A minimal reproducible example or link to a public repository
Assuming we're on Linux, create the following:
go.mod
go 1.25
module example.com/modlinux.go
//go:build linux
package main
func main() { println("running on linux") }windows.go
//go:build windows
// +build windows
package main
func main() { println("running on windows") }.golangci.yml
version: "2"
linters:
enable:
- govetRunning golangci-lint reports the old-style +build line in windows.go, via govet:
$ golangci-lint run
windows.go:2:1: buildtag: +build line is no longer needed (govet)
// +build windows
^
1 issues:
* govet: 1Delete said line and run it again. The error is still being reported, only now line 2 is now blank:
$ sed -i 2D windows.go
$ golangci-lint run
windows.go:2:1: buildtag: +build line is no longer needed (govet)
^
1 issues:
* govet: 1If we clear the cache it goes away:
$ golangci-lint cache clean
$ golangci-lint run
0 issues.Validation
- Yes, I've included all information above (version, config, etc.).
Supporter
- I am a sponsor/backer through GitHub or OpenCollective