Skip to content

exclude-dirs not working #5015

@nekohasekai

Description

@nekohasekai

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

Description of the problem

exclude-dirs seems to be ignored since v1.60.0, the same steps worked fine in v1.59.0 with go1.22.7.

Version of golangci-lint

$ golangci-lint --version
# golangci-lint has version v1.61.0 built with go1.23.1 from (unknown, modified: ?, mod sum: "h1:VvbOLaRVWmyxCnUIMTbf1kDsaJbTzH20FAMXTAlQGu8=") on (unknown)

Configuration

golangci-lint run --exclude-dirs bugpkg

Go environment

$ go version && go env
go version go1.23.1 darwin/arm64
GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/sekai/Library/Caches/go-build'
GOENV='/Users/sekai/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/sekai/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/sekai/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.23.1/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.23.1/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.23.1'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/sekai/Library/Application Support/go/telemetry'
GCCGO='gccgo'
GOARM64='v8.0'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/62/0rdd_81n5jbf6j4w3pcmwycr0000gn/T/go-build3375113623=/tmp/go-build -gno-record-gcc-switches -fno-common'

Verbose output of running

$ golangci-lint cache clean
$  golangci-lint run --exclude-dirs bugpkg/ -v
INFO golangci-lint has version v1.61.0 built with go1.23.1 from (unknown, modified: ?, mod sum: "h1:VvbOLaRVWmyxCnUIMTbf1kDsaJbTzH20FAMXTAlQGu8=") on (unknown) 
INFO [config_reader] Config search paths: [./ /Users/sekai/Projects/lintbug /Users/sekai/Projects /Users/sekai /Users /] 
INFO [lintersdb] Active 6 linters: [errcheck gosimple govet ineffassign staticcheck unused] 
INFO [loader] Go packages loading at mode 575 (compiled_files|deps|exports_file|imports|files|name|types_sizes) took 80.058458ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 83.375µs 
INFO [linters_context/goanalysis] analyzers took 12.492663ms with top 10 stages: ctrlflow: 874.917µs, fact_deprecated: 609.834µs, printf: 565.625µs, SA4006: 494.626µs, buildir: 494.208µs, SA4000: 467.583µs, timeformat: 366.75µs, inspect: 340.75µs, SA9002: 327.583µs, S1008: 325.626µs 
INFO [runner] Issues before processing: 170, after processing: 1 
INFO [runner] Processors filtering stat (in/out): nolint: 170/170, max_same_issues: 1/1, path_prefixer: 1/1, sort_results: 1/1, autogenerated_exclude: 170/170, path_prettifier: 170/170, skip_files: 170/170, exclude: 170/170, exclude-rules: 170/170, severity-rules: 1/1, invalid_issue: 170/170, diff: 1/1, path_shortener: 1/1, fixer: 1/1, identifier_marker: 170/170, filename_unadjuster: 170/170, skip_dirs: 170/170, uniq_by_line: 170/1, max_per_file_from_linter: 1/1, max_from_linter: 1/1, source_code: 1/1, cgo: 170/170 
INFO [runner] processing took 2.395041ms with stages: identifier_marker: 2.2965ms, path_prettifier: 47.749µs, source_code: 12.375µs, nolint: 7.459µs, cgo: 5.249µs, invalid_issue: 4.459µs, filename_unadjuster: 4.416µs, uniq_by_line: 3.917µs, skip_dirs: 3.876µs, autogenerated_exclude: 3.251µs, exclude-rules: 2.541µs, path_shortener: 876ns, max_same_issues: 750ns, max_from_linter: 374ns, max_per_file_from_linter: 291ns, diff: 250ns, skip_files: 208ns, exclude: 167ns, sort_results: 167ns, fixer: 125ns, severity-rules: 41ns, path_prefixer: 0s 
INFO [runner] linters took 18.300208ms with stages: goanalysis_metalinter: 15.869416ms 
bugpkg/bug.go:3:10: could not import golang.org/x/sys/windows (-: build constraints exclude all Go files in /Users/sekai/go/pkg/mod/golang.org/x/sys@v0.25.0/windows) (typecheck)
import _ "golang.org/x/sys/windows"
         ^
INFO File cache stats: 1 entries of total size 52B 
INFO Memory: 3 samples, avg is 29.4MB, max is 30.9MB 
INFO Execution took 103.869042ms

A minimal reproducible example or link to a public repository

go.mod

module lintbug

go 1.23.1

require golang.org/x/sys v0.25.0

main.go

package main

func main() {
  println("Hello world")
}

bugpkg/bug.go

package bugpkg

import _ "golang.org/x/sys/windows" // some platform specified code without //go:build
$ golangci-lint run --exclude-dirs bugpkg

bugpkg/bug.go:3:10: could not import golang.org/x/sys/windows (-: build constraints exclude all Go files in /Users/sekai/go/pkg/mod/golang.org/x/sys@v0.25.0/windows) (typecheck)
import _ "golang.org/x/sys/windows"
         ^

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