Closed
Description
It doesn't seem to be possible to run exportloopref
by itself, even on the simplest of packages. For example, this single file that imports fmt
can't be analyzed:
package main
import "fmt"
func main() {
fmt.Println("hello")
}
$ golangci-lint run --no-config --disable-all --enable exportloopref
WARN [runner] Can't run linter exportloopref: inspect: analysis skipped: errors in package: [/Users/cbandy/tmp/go/main.go:3:8: could not import fmt (Config.Importer.Import(fmt) returned nil but no error)]
ERRO Running error: inspect: analysis skipped: errors in package: [/Users/cbandy/tmp/go/main.go:3:8: could not import fmt (Config.Importer.Import(fmt) returned nil but no error)]
$ golangci-lint run --no-config --disable-all --enable exportloopref --verbose
INFO [lintersdb] Active 1 linters: [exportloopref]
INFO [loader] Go packages loading at mode 7 (compiled_files|files|name) took 322.614921ms
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 1.58944ms
INFO [linters context/goanalysis] analyzers took 66.964µs with top 10 stages: exportloopref: 45.094µs, inspect: 21.87µs
WARN [runner] Can't run linter exportloopref: inspect: analysis skipped: errors in package: [/Users/cbandy/tmp/go/main.go:3:8: could not import fmt (Config.Importer.Import(fmt) returned nil but no error)]
INFO [runner] processing took 8.453µs with stages: nolint: 2.748µs, max_same_issues: 2.44µs, cgo: 431ns, skip_dirs: 409ns, path_prettifier: 350ns, autogenerated_exclude: 306ns, path_prefixer: 291ns, filename_unadjuster: 260ns, max_from_linter: 203ns, skip_files: 148ns, uniq_by_line: 137ns, diff: 137ns, identifier_marker: 131ns, sort_results: 73ns, max_per_file_from_linter: 68ns, source_code: 67ns, exclude: 67ns, path_shortener: 66ns, exclude-rules: 61ns, severity-rules: 60ns
INFO [runner] linters took 2.534605ms with stages: exportloopref: 2.482917ms
ERRO Running error: inspect: analysis skipped: errors in package: [/Users/cbandy/tmp/go/main.go:3:8: could not import fmt (Config.Importer.Import(fmt) returned nil but no error)]
INFO Memory: 6 samples, avg is 71.6MB, max is 71.6MB
INFO Execution took 405.393236ms
I've tried the latest release and built from @master
.
- Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
- Yes, I've searched similar issues on GitHub and didn't find any.
- Yes, I've included all information below (version, config, etc).
Please include the following information:
Version of golangci-lint
$ golangci-lint --version
golangci-lint has version 1.32.2 built from 52d26a3 on 2020-11-03T01:15:38Z
and
golangci-lint has version v1.32.3-0.20201117214611-c68692e99f34 built from (unknown, mod sum: "h1:TwcnmNXfBsx0UdOb3BaF0B2PYYdtEV11+Ad1qP1xMD4=") on (unknown)
Config file
$ cat .golangci.yml
cat: .golangci.yml: No such file or directory
Go environment
$ go version && go env
go version go1.15.3 darwin/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/cbandy/Library/Caches/go-build"
GOENV="/Users/cbandy/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/cbandy/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/cbandy/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/cbandy/.local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/cbandy/.local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/cbandy/tmp/go/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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/bw/_dxdzsmx6h1ffcgp6rvfh55c0000gn/T/go-build901332976=/tmp/go-build -gno-record-gcc-switches -fno-common"
Verbose output of running
$ golangci-lint cache clean
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /Users/cbandy/tmp/go /Users/cbandy/tmp /Users/cbandy /Users /]
INFO [lintersdb] Active 10 linters: [deadcode errcheck gosimple govet ineffassign staticcheck structcheck typecheck unused varcheck]
INFO [loader] Go packages loading at mode 575 (deps|exports_file|files|imports|name|compiled_files|types_sizes) took 289.052724ms
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 191.856µs
INFO [linters context/goanalysis] analyzers took 974.81474ms with top 10 stages: buildir: 705.474977ms, fact_purity: 86.725757ms, ctrlflow: 55.909102ms, inspect: 46.534415ms, printf: 44.046748ms, fact_deprecated: 34.00492ms, S1030: 131.503µs, ineffassign: 100.069µs, SA4021: 93.871µs, isgenerated: 89.483µs
INFO [linters context/goanalysis] analyzers took 2.766319ms with top 10 stages: buildir: 2.605689ms, U1000: 160.63µs
INFO [runner] processing took 7.439µs with stages: max_same_issues: 2.608µs, nolint: 1.929µs, skip_dirs: 374ns, cgo: 275ns, max_from_linter: 271ns, path_prettifier: 270ns, skip_files: 218ns, filename_unadjuster: 179ns, path_prefixer: 172ns, autogenerated_exclude: 168ns, uniq_by_line: 151ns, diff: 146ns, identifier_marker: 145ns, path_shortener: 80ns, source_code: 80ns, max_per_file_from_linter: 78ns, sort_results: 77ns, exclude: 75ns, exclude-rules: 73ns, severity-rules: 70ns
INFO [runner] linters took 2.138641413s with stages: goanalysis_metalinter: 2.101323097s, unused: 37.254885ms
INFO File cache stats: 0 entries of total size 0B
INFO Memory: 26 samples, avg is 150.1MB, max is 207.4MB
INFO Execution took 2.441623457s