Thank you for creating the issue!
Please include the following information:
Version of golangci-lint
$ golangci-lint --version
golangci-lint has version 1.21.0 built from 645e794 on 2019-10-15T18:16:56Z
Config file
$ golangci-lint config path
WARN No config file detected
Go environment
$ go version && go env
go version go1.14beta1 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/yann/.cache/go-build"
GOENV="/home/yann/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY="github.com/ulule/*"
GONOSUMDB="github.com/ulule/*"
GOOS="linux"
GOPATH="/home/yann/go"
GOPRIVATE="github.com/ulule/*"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/yann/sdk/go1.14beta1"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/yann/sdk/go1.14beta1/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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-build756039823=/tmp/go-build -gno-record-gcc-switches"
Verbose output of running
$ cd $(mktemp -d)
$ cat > main.go
package main
import "fmt"
func main() {
fmt.Println("vim-go")
}
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /tmp/tmp.Cfm36xuyQn /tmp /]
INFO [lintersdb] Active 10 linters: [deadcode errcheck gosimple govet ineffassign staticcheck structcheck typecheck unused varcheck]
INFO [loader] Go packages loading at mode 575 (types_sizes|deps|exports_file|files|name|compiled_files|imports) took 72.396647ms
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 84.595µs
INFO [runner/unused/goanalysis] analyzers took 29.678µs with top 10 stages: U1000: 15.231µs, buildssa: 14.447µs
WARN [runner] Can't run linter unused: buildssa: analysis skipped: errors in package: [/tmp/tmp.Cfm36xuyQn/main.go:3:8: could not import fmt (/home/yann/sdk/go1.14beta1/src/fmt/errors.go:7:8: could not import errors (/home/yann/sdk/go1.14beta1/src/errors/wrap.go:8:2: could not import internal/reflectlite (/home/yann/sdk/go1.14beta1/src/internal/reflectlite/value.go:8:2: could not import runtime (/home/yann/sdk/go1.14beta1/src/runtime/alg.go:8:2: could not import internal/cpu (-: could not load export data: cannot import "internal/cpu" (unknown iexport format version 1), export data is newer version - update tool)))))]
INFO [runner/goanalysis_metalinter/goanalysis] analyzers took 2.849579ms with top 10 stages: fact_deprecated: 696.048µs, inspect: 256.558µs, buildssa: 234.286µs, ctrlflow: 203.868µs, fact_purity: 199.656µs, printf: 196.927µs, SA1000: 19.86µs, S1005: 17.648µs, asmdecl: 16.062µs, S1019: 14.203µs
WARN [runner] Can't run linter goanalysis_metalinter: assign: failed prerequisites: inspect@_/tmp/tmp.Cfm36xuyQn
INFO [runner] processing took 2.705µs with stages: max_same_issues: 503ns, diff: 307ns, skip_dirs: 297ns, max_from_linter: 237ns, filename_unadjuster: 196ns, nolint: 173ns, cgo: 148ns, skip_files: 136ns, path_prettifier: 135ns, identifier_marker: 134ns, autogenerated_exclude: 132ns, max_per_file_from_linter: 60ns, uniq_by_line: 51ns, exclude: 51ns, source_code: 49ns, exclude-rules: 48ns, path_shortener: 48ns
INFO [runner] linters took 648.319905ms with stages: unused: 643.908089ms, goanalysis_metalinter: 4.380376ms
INFO File cache stats: 0 entries of total size 0B
INFO Memory: 9 samples, avg is 113.4MB, max is 136.1MB
INFO Execution took 724.753556ms
There are two warnings in the output, the first is this issue, the second looks like https://github.com/golangci/golangci-lint/issues/827.
The issue is present for versions 1.21.0, 1.20.1 and 1.20.0. It is not present for version 1.19.1.
Hi, thank you for report.
Is it only for go1.14?
Probably we should rebuild golangci-lint with go1.14 after the release, but I'm not sure that it will help.
I was able to reproduce with Go 1.14.x and latest master. The fix is to update x/tools to a more recent version.
cc @jirfag
Be careful, if you update to a more recent version of x/tools, it causes some issues with the govet linter.
https://github.com/golangci/golangci-lint/blob/cb2f8ba5620361ab997b71e95e03ea28d30014cf/pkg/golinters/govet.go#L80-L83
This condition matches for some analyzers, such as printf, because they changed it in x/tools "recently".
If you configure the key linters-settings.govet.settings.printf in the config file, it will throw an error about unknown/invalid key.
This error occurred for me, because I was not able to run golangci-lint with Go 1.14.
So I decided to install it with go get.
I was working fine with v1.21.0, but since v1.22.0 it's broken. (due to the x/tools update)
I learned recently that it's not recommended to install golangci-lint with go get.
BTW, go get is used by vscode-go, so it's also broken now.
@pierrre Thanks for the follow up. We actually haven't updated x/tools in any releases since we are using an explicit replace directive in the go.mod. This is not carried transitively when using go get in a downstream project. Can confirm this on your end by copying the directive into your own project's go.mod file?
by copying the directive into your own project's
go.modfile?
I can't do it, because I'm not using it in a project.
I'm installing it "globally" on my system.
But I'm sure that the replace is the cause.
Most helpful comment
I was able to reproduce with Go 1.14.x and latest
master. The fix is to updatex/toolsto a more recent version.cc @jirfag