You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With v2, if a rule in linters.exclusions.rules contains source: ... matches, and the tool is invoked from a subdirectory (instead of the directory where the .golangci.yml resides), the exclusions are ignored and a warning similar to the following is printed:
WARN [runner/exclusion_rules] Failed to get line bar/bar.go:11 from line cache: failed to get file bar/bar.go lines cache: can't get file bar/bar.go bytes from cache: can't read file bar/bar.go: open bar/bar.go: no such file or directory
Version of golangci-lint
$ golangci-lint --versiongolangci-lint has version 2.0.1 built with go1.24.1 from e8927ce2 on 2025-03-24T20:34:31Z
Configuration
version: "2"linters:
exclusions:
rules:
- linters: [errcheck]text: Error return value of `[^`]+.Close` is not checkedsource: ^\s*defer\s
Go environment
$ go version && go envgo version go1.24.1 darwin/arm64AR='ar'CC='clang'CGO_CFLAGS='-O2 -g'CGO_CPPFLAGS=''CGO_CXXFLAGS='-O2 -g'CGO_ENABLED='1'CGO_FFLAGS='-O2 -g'CGO_LDFLAGS='-O2 -g'CXX='clang++'GCCGO='gccgo'GO111MODULE=''GOARCH='arm64'GOARM64='v8.0'GOAUTH='netrc'GOBIN=''GOCACHE='/Users/abhinav/Library/Caches/go-build'GOCACHEPROG=''GODEBUG=''GOENV='/Users/abhinav/Library/Application Support/go/env'GOEXE=''GOEXPERIMENT=''GOFIPS140='off'GOFLAGS=''GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/pd/cc8pg8hn42vg9dz7r_84t_rm0000gn/T/go-build1105924328=/tmp/go-build -gno-record-gcc-switches -fno-common'GOHOSTARCH='arm64'GOHOSTOS='darwin'GOINSECURE=''GOMOD='/Users/abhinav/src/exp/golangci-lint-v2-repro/go.mod'GOMODCACHE='/Users/abhinav/go/pkg/mod'GOOS='darwin'GOPATH='/Users/abhinav/go'GOPROXY='https://proxy.golang.org,direct'GOROOT='/Users/abhinav/.local/share/mise/installs/go/1.24.1'GOSUMDB='sum.golang.org'GOTELEMETRY='on'GOTELEMETRYDIR='/Users/abhinav/Library/Application Support/go/telemetry'GOTMPDIR=''GOTOOLCHAIN='auto'GOTOOLDIR='/Users/abhinav/.local/share/mise/installs/go/1.24.1/pkg/tool/darwin_arm64'GOVCS=''GOVERSION='go1.24.1'GOWORK=''PKG_CONFIG='pkg-config'
Verbose output of running
$ golangci-lint cache clean
$ golangci-lint run -vINFO golangci-lint has version 2.0.1 built with go1.24.1 from e8927ce2 on 2025-03-24T20:34:31ZINFO [config_reader] Config search paths: [./ /Users/abhinav/src/exp/golangci-lint-v2-repro/bar /Users/abhinav/src/exp/golangci-lint-v2-repro /Users/abhinav/src/exp /Users/abhinav/src /Users/abhinav /Users /]INFO [config_reader] Used config file ../.golangci.ymlINFO maxprocs: Leaving GOMAXPROCS=10: CPU quota undefinedINFO [goenv] Read go env for 5.933667ms: map[string]string{"GOCACHE":"/Users/abhinav/Library/Caches/go-build", "GOROOT":"/Users/abhinav/.local/share/mise/installs/go/1.24.1"}INFO [lintersdb] Active 5 linters: [errcheck govet ineffassign staticcheck unused]INFO [loader] Go packages loading at mode 8767 (name|types_sizes|compiled_files|exports_file|files|imports|deps) took 454.833417msINFO [runner/filename_unadjuster] Pre-built 0 adjustments in 900.5µsINFO [linters_context/goanalysis] analyzers took 481.463863ms with top 10 stages: buildir: 297.471829ms, printf: 28.921206ms, ctrlflow: 27.20283ms, fact_deprecated: 26.42971ms, SA5012: 24.823462ms, fact_purity: 23.408038ms, nilness: 16.751123ms, inspect: 15.411585ms, typedness: 14.123455ms, tokenfileanalyzer: 4.07767msWARN [runner/exclusion_rules] Failed to get line bar/bar.go:11 from line cache: failed to get file bar/bar.go lines cache: can't get file bar/bar.go bytes from cache: can't read file bar/bar.go: open bar/bar.go: no such file or directoryINFO [runner/exclusion_rules] Skipped 0 issues by rules: [Text: "Error return value of `[^`]+.Close` is not checked", Source: "^\\s*defer\\s", Linters: "errcheck"]INFO [runner] Processors filtering stat (in/out): diff: 1/1, path_prettifier: 1/1, filename_unadjuster: 1/1, invalid_issue: 1/1, nolint_filter: 1/1, max_per_file_from_linter: 1/1, max_from_linter: 1/1, severity-rules: 1/1, path_absoluter: 1/1, cgo: 1/1, exclusion_paths: 1/1, fixer: 1/1, max_same_issues: 1/1, source_code: 1/1, path_relativity: 1/1, generated_file_filter: 1/1, exclusion_rules: 1/1, uniq_by_line: 1/1, path_shortener: 1/1, sort_results: 1/1INFO [runner] processing took 98.418µs with stages: nolint_filter: 24.292µs, generated_file_filter: 20.708µs, exclusion_rules: 17.792µs, cgo: 14.25µs, source_code: 13µs, sort_results: 3.25µs, path_relativity: 1.291µs, uniq_by_line: 1.167µs, max_same_issues: 500ns, path_shortener: 459ns, invalid_issue: 375ns, fixer: 292ns, filename_unadjuster: 209ns, max_from_linter: 209ns, exclusion_paths: 167ns, path_absoluter: 167ns, max_per_file_from_linter: 124ns, diff: 83ns, path_prettifier: 83ns, severity-rules: 0sINFO [runner] linters took 404.248375ms with stages: goanalysis_metalinter: 404.117459msbar/bar.go:11:15: Error return value of `f.Close` is not checked (errcheck) defer f.Close() ^1 issues:* errcheck: 1INFO File cache stats: 1 entries of total size 114BINFO Memory: 10 samples, avg is 107.4MB, max is 289.1MBINFO Execution took 866.396291ms
A minimal reproducible example or link to a public repository
golangci-lint run from the root directory passes just fine, but from the bar directory fails with:
❮ golangci-lint run
WARN [runner/exclusion_rules] Failed to get line bar/bar.go:11 from line cache: failed to get file bar/bar.go lines cache: can't get file bar/bar.go bytes from cache: can't read file bar/bar.go: open bar/bar.go: no such file or directory
bar/bar.go:11:15: Error return value of `f.Close` is not checked (errcheck)
defer f.Close()
Validation
Yes, I've included all information above (version, config, etc.).
Welcome
typecheck
section of the FAQ.How did you install golangci-lint?
I don't know
Description of the problem
With v2, if a rule in
linters.exclusions.rules
containssource: ...
matches, and the tool is invoked from a subdirectory (instead of the directory where the .golangci.yml resides), the exclusions are ignored and a warning similar to the following is printed:Version of golangci-lint
Configuration
Go environment
Verbose output of running
A minimal reproducible example or link to a public repository
Given the following layout:
golangci-lint run
from the root directory passes just fine, but from thebar
directory fails with:Validation
Supporter
The text was updated successfully, but these errors were encountered: