Thank you for creating the issue!
Please include the following information:
Version of golangci-lint
$ golangci-lint version
golangci-lint has version 1.22.2 built from cb2f8ba on 2019-12-30T19:26:28Z```
Config file
$ cat .golangci.yml
linters:
# please, do not use `enable-all`: it's deprecated and will be removed soon.
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
disable-all: true
enable:
#notskip- bodyclose
#notskip- deadcode
#notskip- depguard
#- dogsled
#- dupl
#notskip- errcheck
#- funlen
#- gochecknoinits
#- goconst
#notskip- gocritic
#- gocyclo
#- gofmt
#- goimports
#- golint
#notskip- gosec
#notskip- gosimple
#notskip- govet
#- ineffassign
#notskip- interfacer
#- lll
#- misspell
#- nakedret
#- scopelint
#notskip- staticcheck
#notskip- structcheck
#notskip- stylecheck
#- typecheck
- unconvert
#notskip- unparam
#notskip- unused
#notskip- varcheck
#- whitespace
# don't enable:
#- gochecknoglobals
#- gocognit
#- godox
#notskip- maligned
#- prealloc
run:
skip-dirs:
- api
- vendor
Go environment
$ go version && go env
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/repo/go:/k10/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/repo/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build302036891=/tmp/go-build -gno-record-gcc-switches"
Verbose output of running
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /repo/go/src /repo/go /repo /]
INFO [config_reader] Used config file ../../.golangci.yml
INFO [lintersdb] Active 1 linters: [unconvert]
INFO [lintersdb] Active 1 linters: [unconvert]
INFO [loader] Go packages loading at mode 575 (deps|types_sizes|compiled_files|exports_file|files|imports|name) took 2.72833563s
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 76.405679ms
INFO [runner/unconvert/goanalysis] analyzers took 85.820662ms with top 10 stages: unconvert: 85.820662ms
WARN [runner] Can't run linter unconvert: unconvert: analysis skipped: errors in package: [/repo/go/src/api/.../run.go:57:19: client.Actions undefined (type client.Interface has no field or method Actions) /repo/go/src/api/.../run.go:51:19: client.Actions undefined (type client.Interface has no field or method Actions) /repo/go/src/api/.../retire.go:57:19: client.Actions undefined (type client.Interface has no field or method Actions) /repo/go/src/api/.../retire.go:51:19: client.Actions undefined (type client.Interface has no field or method Actions) /repo/go/src/api/.../restore.go:58:19: client.Actions undefined (type client.Interface has no field or method Actions) /repo/go/src/api/.../restore.go:52:19: client.Actions undefined (type client.Interface has no field or method Actions) /repo/go/src/api/.../import.go:58:19: client.Actions undefined (type client.Interface has no field or method Actions) /repo/go/src/api/.../import.go:52:19: client.Actions undefined (type client.Interface has no field or method Actions) /repo/go/src/api/.../export.go:58:19: client.Actions undefined (type client.Interface has no field or method Actions) /repo/go/src/api/.../export.go:52:19: client.Actions undefined (type client.Interface has no field or method Actions) /repo/go/src/api/.../backup.go:58:19: client.Actions undefined (type client.Interface has no field or method Actions) /repo/go/src/api/.../backup.go:52:19: client.Actions undefined (type client.Interface has no field or method Actions)]
INFO [runner] processing took 2.531碌s with stages: max_same_issues: 558ns, skip_dirs: 288ns, nolint: 253ns, max_from_linter: 237ns, cgo: 198ns, path_prettifier: 108ns, autogenerated_exclude: 107ns, skip_files: 104ns, filename_unadjuster: 102ns, exclude-rules: 101ns, max_per_file_from_linter: 100ns, diff: 99ns, identifier_marker: 99ns, uniq_by_line: 48ns, exclude: 46ns, source_code: 42ns, path_shortener: 41ns
INFO [runner] linters took 1.729615347s with stages: unconvert: 1.729587635s
ERRO Running error: unconvert: analysis skipped: errors in package: [/repo/go/src/api/.../run.go:57:19: client.Actions undefined (type client.Interface has no field or method Actions) /repo/go/src/api/.../run.go:51:19: client.Actions undefined (type client.Interface has no field or method Actions) /repo/go/src/api/.../retire.go:57:19: client.Actions undefined (type client.Interface has no field or method Actions) /repo/go/src/api/.../retire.go:51:19: client.Actions undefined (type client.Interface has no field or method Actions) /repo/go/src/api/.../restore.go:58:19: client.Actions undefined (type client.Interface has no field or method Actions) /repo/go/src/api/.../restore.go:52:19: client.Actions undefined (type client.Interface has no field or method Actions) /repo/go/src/api/.../import.go:58:19: client.Actions undefined (type client.Interface has no field or method Actions) /repo/go/src/api/.../import.go:52:19: client.Actions undefined (type client.Interface has no field or method Actions) /repo/go/src/api/.../export.go:58:19: client.Actions undefined (type client.Interface has no field or method Actions) /repo/go/src/api/.../export.go:52:19: client.Actions undefined (type client.Interface has no field or method Actions) /repo/go/src/api/.../backup.go:58:19: client.Actions undefined (type client.Interface has no field or method Actions) /repo/go/src/api/.../backup.go:52:19: client.Actions undefined (type client.Interface has no field or method Actions)]
INFO Memory: 47 samples, avg is 176.6MB, max is 404.3MB
INFO Execution took 4.545652859s
Linters that adhere to skip-dirs
dogsled
dupl
funlen
gochecknoinits
goconst
gocyclo
gofmt
goimports
golint
ineffassign
lll
misspell
nakedret
scopelint
typecheck
whitespace
gochecknoglobals
gocognit
godox
prealloc
Linters that ignore to skip-dirs
bodyclose
deadcode
depguard
errcheck
gocritic
gosec
gosimple
govet
interfacer
staticcheck
structcheck
stylecheck
unconvert
unparam
unused
varcheck
maligned
Perhaps that there is a reason that skip-dirs is ignored with some linters and a non-zero value is returned for errors in those directories, but I cannot seem to find one. Any help would be very welcome.
I think that it is not related to skip-dirs and just another version of #885
Currently we are working on a proper fix, but workaround is described in #885: you can just disable "unused" linter or use earlier version of golangci.
I'm not sure that would be the case. It happens when I run only one linter at a time. I've tried each of them individually.
Thank you for input, you are right.
Probably it is because some linters require types info to begin analysis, and skip-dirs does not exclude packages from parsing and analysis, just ignores the issues for files from that dirs.
If it just ignored issues for those and returned a 0 instead of a non-zero result, that would be fine, but even when the only issue that is found is in one of those dirs, a non-zero result is returned.
Through further testing (including tweaking the skip-dirs values and changing default concurrency to 8, I have been able to get all linters except the following 9 in the repo's current .golangci.yml file to work:
bodyclose
gomnd
gosimple
govet
interfacer
staticcheck
stylecheck
unparam
unused
whitespace is another that can cause this issue.
golangci-lint run --no-config --disable-all --skip-dirs pkg/simpletemplate -E whitespace
WARN [runner] Can't run linter whitespace: whitespace: failed to get line <snip>/pkg/simpletemplate/yaccpar:329: failed to get file <snip>/pkg/simpletemplate/yaccpar lines cache: can't get file <snip>/pkg/simpletemplate/yaccpar bytes from cache: can't read file <snip>/pkg/simpletemplate/yaccpar: open <snip>/pkg/simpletemplate/yaccpar: no such file or directory
ERRO Running error: whitespace: failed to get line <snip>/pkg/simpletemplate/yaccpar:329: failed to get file <snip>/pkg/simpletemplate/yaccpar lines cache: can't get file <snip>/pkg/simpletemplate/yaccpar bytes from cache: can't read file <snip>/pkg/simpletemplate/yaccpar: open <snip>/pkg/simpletemplate/yaccpar: no such file or directory
This error doesn't happen f.e. when swapping whitespace for govet.
Do you have any progress on this issue?
In my case, this bug blocks the usage golangci-lint completely (at least I haven't found any workaround yet). I have a folder that contains code templates, some of them are .go files. They can not (and should not) be compiled. However, the linter somehow tries to compile them and fails with the error:
level=error msg="Running error: buildir: failed to load package : could not load export data: no export data for \"project-name/db\""
I too am experiencing this problem 馃槥
Most helpful comment
Do you have any progress on this issue?
In my case, this bug blocks the usage
golangci-lintcompletely (at least I haven't found any workaround yet). I have a folder that contains code templates, some of them are.gofiles. They can not (and should not) be compiled. However, the linter somehow tries to compile them and fails with the error: