Skip to content

could not run linter xxx:buildssa: analysis skipped: errors in package: xxx could not import xxx #896

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
3 tasks done
ydcool opened this issue Dec 25, 2019 · 22 comments
Closed
3 tasks done
Labels
bug Something isn't working cursed This issue is doomed. feedback required Requires additional feedback

Comments

@ydcool
Copy link

ydcool commented Dec 25, 2019

Thank you for creating the issue!

  • 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.21.0 built from 645e794 on 2019-10-15T18:15:04Z
Config file
$ cat .golangci.yml
cat: .golangci.yml: No such file or directory
Go environment
$ go version && go env
go version go1.13.4 windows/amd64
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\yindongchao\AppData\Local\go-build
set GOENV=C:\Users\yindongchao\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GONOPROXY=*.gitlab.com,*.gitee.com,*.inspur.com
set GONOSUMDB=*.gitlab.com,*.gitee.com,*.inspur.com
set GOOS=windows
set GOPATH=C:\Users\yindongchao\go
set GOPRIVATE=*.gitlab.com,*.gitee.com,*.inspur.com
set GOPROXY=https://goproxy.io
set GOROOT=c:\go
set GOSUMDB=off
set GOTMPDIR=
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\YINDON~1\AppData\Local\Temp\go-build718758610=/tmp/go-build -gno-record-gcc-switches
Verbose output of running
$ golangci-lint run -v
C:\Users\yindongchao\go\bin\golangci-lint.exe run -v --disable=typecheck --enable=bodyclose --enable=dogsled --enable=gocritic --enable=gocyclo --enable=golint --enable=gosec --enable=maligned --enable=prealloc --enable=stylecheck D:\Repo\git.inspur.com\inspur-cloud\g5-storage\pkg\incloud
level=info msg="[config_reader] Config search paths: [./ D:\\Repo\\git.inspur.com\\inspur-cloud\\g5-storage\\pkg\\incloud D:\\Repo\\git.inspur.com\\inspur-cloud\\g5-storage\\pkg D:\\Repo\\git.inspur.com\\inspur-cloud\\g5-storage D:\\Repo\\git.inspur.com\\inspur-cloud D:\\Repo\\git.inspur.com D:\\Repo D:\\]"
level=info msg="[lintersdb] Active 18 linters: [bodyclose deadcode dogsled errcheck gocritic gocyclo golint gosec gosimple govet ineffassign maligned prealloc staticcheck structcheck stylecheck unused varcheck]"
level=info msg="[loader] Go packages loading at mode 575 (deps|files|imports|name|compiled_files|types_sizes|exports_file) took 1.3535824s"
level=info msg="[runner/filename_unadjuster] Pre-built 0 adjustments in 2.4803ms"
level=info msg="[runner/goanalysis_metalinter/goanalysis] analyzers took 1.488ms with top 10 stages: errcheck: 496µs, buildssa: 496µs, S1011: 496µs, unreachable: 0s, ST1011: 0s, SA5009: 0s, SA4008: 0s, S1019: 0s, fact_deprecated: 0s, shift: 0s"
level=warning msg="[runner] Can't run linter goanalysis_metalinter: buildssa: analysis skipped: errors in package: [D:\\Repo\\git.inspur.com\\inspur-cloud\\g5-storage\\pkg\\incloud\\brainkeeper.go:13:2: could not import k8s.io/client-go/kubernetes (C:\\Users\\yindongchao\\go\\pkg\\mod\\k8s.io\\[email protected]\\kubernetes\\clientset.go:24:12: could not import k8s.io/client-go/discovery (C:\\Users\\yindongchao\\go\\pkg\\mod\\k8s.io\\[email protected]\\discovery\\discovery_client.go:39:13: could not import k8s.io/client-go/rest (C:\\Users\\yindongchao\\go\\pkg\\mod\\k8s.io\\[email protected]\\rest\\transport.go:24:2: could not import k8s.io/client-go/plugin/pkg/client/auth/exec (C:\\Users\\yindongchao\\go\\pkg\\mod\\k8s.io\\[email protected]\\plugin\\pkg\\client\\auth\\exec\\exec.go:35:2: could not import golang.org/x/crypto/ssh/terminal (C:\\Users\\yindongchao\\go\\pkg\\mod\\golang.org\\x\\[email protected]\\ssh\\terminal\\util_windows.go:97:36: 2-valued windows.GetCurrentProcess() (value of type (windows.Handle, error)) where single value is expected))))) D:\\Repo\\git.inspur.com\\inspur-cloud\\g5-storage\\pkg\\incloud\\brainkeeper.go:14:2: could not import k8s.io/client-go/tools/leaderelection/resourcelock (C:\\Users\\yindongchao\\go\\pkg\\mod\\k8s.io\\[email protected]\\tools\\leaderelection\\resourcelock\\configmaplock.go:26:15: could not import k8s.io/client-go/kubernetes/typed/core/v1 (C:\\Users\\yindongchao\\go\\pkg\\mod\\k8s.io\\[email protected]\\kubernetes\\typed\\core\\v1\\componentstatus.go:29:7: could not import k8s.io/client-go/rest (C:\\Users\\yindongchao\\go\\pkg\\mod\\k8s.io\\[email protected]\\rest\\transport.go:24:2: could not import k8s.io/client-go/plugin/pkg/client/auth/exec (C:\\Users\\yindongchao\\go\\pkg\\mod\\k8s.io\\[email protected]\\plugin\\pkg\\client\\auth\\exec\\exec.go:35:2: could not import golang.org/x/crypto/ssh/terminal (C:\\Users\\yindongchao\\go\\pkg\\mod\\golang.org\\x\\[email protected]\\ssh\\terminal\\util_windows.go:97:36: 2-valued windows.GetCurrentProcess() (value of type (windows.Handle, error)) where single value is expected)))))]"
level=info msg="[runner/unused/goanalysis] analyzers took 0s with top 10 stages: buildssa: 0s, U1000: 0s"
level=warning msg="[runner] Can't run linter unused: buildssa: analysis skipped: errors in package: [D:\\Repo\\git.inspur.com\\inspur-cloud\\g5-storage\\pkg\\incloud\\brainkeeper.go:13:2: could not import k8s.io/client-go/kubernetes (C:\\Users\\yindongchao\\go\\pkg\\mod\\k8s.io\\[email protected]\\kubernetes\\clientset.go:24:12: could not import k8s.io/client-go/discovery (C:\\Users\\yindongchao\\go\\pkg\\mod\\k8s.io\\[email protected]\\discovery\\discovery_client.go:39:13: could not import k8s.io/client-go/rest (C:\\Users\\yindongchao\\go\\pkg\\mod\\k8s.io\\[email protected]\\rest\\transport.go:24:2: could not import k8s.io/client-go/plugin/pkg/client/auth/exec (C:\\Users\\yindongchao\\go\\pkg\\mod\\k8s.io\\[email protected]\\plugin\\pkg\\client\\auth\\exec\\exec.go:35:2: could not import golang.org/x/crypto/ssh/terminal (C:\\Users\\yindongchao\\go\\pkg\\mod\\golang.org\\x\\[email protected]\\ssh\\terminal\\util_windows.go:97:36: 2-valued windows.GetCurrentProcess() (value of type (windows.Handle, error)) where single value is expected))))) D:\\Repo\\git.inspur.com\\inspur-cloud\\g5-storage\\pkg\\incloud\\brainkeeper.go:14:2: could not import k8s.io/client-go/tools/leaderelection/resourcelock (C:\\Users\\yindongchao\\go\\pkg\\mod\\k8s.io\\[email protected]\\tools\\leaderelection\\resourcelock\\configmaplock.go:26:15: could not import k8s.io/client-go/kubernetes/typed/core/v1 (C:\\Users\\yindongchao\\go\\pkg\\mod\\k8s.io\\[email protected]\\kubernetes\\typed\\core\\v1\\componentstatus.go:29:7: could not import k8s.io/client-go/rest (C:\\Users\\yindongchao\\go\\pkg\\mod\\k8s.io\\[email protected]\\rest\\transport.go:24:2: could not import k8s.io/client-go/plugin/pkg/client/auth/exec (C:\\Users\\yindongchao\\go\\pkg\\mod\\k8s.io\\[email protected]\\plugin\\pkg\\client\\auth\\exec\\exec.go:35:2: could not import golang.org/x/crypto/ssh/terminal (C:\\Users\\yindongchao\\go\\pkg\\mod\\golang.org\\x\\[email protected]\\ssh\\terminal\\util_windows.go:97:36: 2-valued windows.GetCurrentProcess() (value of type (windows.Handle, error)) where single value is expected)))))]"
level=info msg="[runner] processing took 0s with stages: nolint: 0s, max_per_file_from_linter: 0s, source_code: 0s, cgo: 0s, skip_files: 0s, exclude: 0s, diff: 0s, max_from_linter: 0s, max_same_issues: 0s, path_shortener: 0s, skip_dirs: 0s, identifier_marker: 0s, exclude-rules: 0s, uniq_by_line: 0s, filename_unadjuster: 0s, path_prettifier: 0s, autogenerated_exclude: 0s"
level=info msg="[runner] linters took 1.3243193s with stages: goanalysis_metalinter: 888.3358ms, unused: 435.9835ms"
level=info msg="File cache stats: 0 entries of total size 0B"
level=info msg="Memory: 30 samples, avg is 53.7MB, max is 140.3MB"
level=info msg="Execution took 2.8415811s"

Process finished with exit code 0
@ernado
Copy link
Member

ernado commented Jan 7, 2020

Seems like related to #885

@ernado
Copy link
Member

ernado commented Feb 5, 2020

@ydcool please check latest version, issue should be fixed

@ydcool
Copy link
Author

ydcool commented Feb 6, 2020

@ernado thank you, I'll try it out soon.

@diegoholiveira
Copy link

I'm having the same issue.

ERRO Running error: asmdecl: analysis skipped: errors in package: [serviceunit.go:3:8: could not import fmt (/usr/local/Cellar/go/1.13.8/libexec/src/fmt/format.go:8:2: could not import strconv (/usr/local/Cellar/go/1.13.8/libexec/src/strconv/quote.go:11:2: could not import unicode/utf8 (/usr/local/Cellar/go/1.13.8/libexec/src/unicode/utf8/utf8.go:28:8: expected ';', found b00000000)))]

I'm running the latest version available in brew:

% brew info golangci-lint
golangci/tap/golangci-lint: stable 1.23.6

With Go 1.13:

% go version
go version go1.13.8 darwin/amd64

@Zhangxxamber
Copy link

I'm having the same issue.

ERRO Running error: asmdecl: analysis skipped: errors in package: [serviceunit.go:3:8: could not import fmt (/usr/local/Cellar/go/1.13.8/libexec/src/fmt/format.go:8:2: could not import strconv (/usr/local/Cellar/go/1.13.8/libexec/src/strconv/quote.go:11:2: could not import unicode/utf8 (/usr/local/Cellar/go/1.13.8/libexec/src/unicode/utf8/utf8.go:28:8: expected ';', found b00000000)))]

I'm running the latest version available in brew:

% brew info golangci-lint
golangci/tap/golangci-lint: stable 1.23.6

With Go 1.13:

% go version
go version go1.13.8 darwin/amd64

I also have this problem
$ golangci-lint --version
golangci-lint has version v1.23.6 built from b9eef79 on 2020-02-18 19:29:56
$ go version
go version go1.13.8 windows/amd64

@JuanJoseGonGi
Copy link

JuanJoseGonGi commented Feb 23, 2020

I have the same error

$ golangci-lint run --verbose main.go
INFO [config_reader] Used config file ../.golangci.yml 
INFO [lintersdb] Active 10 linters: [deadcode errcheck gosimple govet ineffassign staticcheck structcheck typecheck unused varcheck] 
INFO [lintersdb] Active 10 linters: [deadcode errcheck gosimple govet ineffassign staticcheck structcheck typecheck unused varcheck] 
INFO [loader] Go packages loading at mode 575 (compiled_files|name|files|imports|types_sizes|deps|exports_file) took 137.659699ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 401.738µs 
INFO [runner/goanalysis_metalinter/goanalysis] analyzers took 2.193889ms with top 10 stages: fact_deprecated: 458.866µs, buildssa: 111.435µs, inspect: 79.572µs, ctrlflow: 42.159µs, printf: 41.873µs, SA4019: 39.139µs, fact_purity: 35.308µs, structcheck: 24.734µs, copylocks: 24.595µs, SA4014: 23.489µs 
WARN [runner] Can't run linter goanalysis_metalinter: assign: failed prerequisites: inspect@command-line-arguments 
INFO [runner/unused/goanalysis] analyzers took 38.104µs with top 10 stages: buildssa: 21.049µs, U1000: 17.055µs 
WARN [runner] Can't run linter unused: buildssa: analysis skipped: errors in package: [main.go:169:44: cannot use process (variable of type models.Process) as *models.Process value in argument to append] 
INFO [runner] processing took 3.458µs with stages: max_same_issues: 697ns, nolint: 461ns, skip_dirs: 419ns, max_from_linter: 329ns, path_prettifier: 201ns, cgo: 181ns, filename_unadjuster: 180ns, identifier_marker: 170ns, autogenerated_exclude: 155ns, diff: 134ns, skip_files: 125ns, exclude: 77ns, uniq_by_line: 74ns, source_code: 65ns, exclude-rules: 65ns, max_per_file_from_linter: 63ns, path_shortener: 62ns 
INFO [runner] linters took 272.240046ms with stages: goanalysis_metalinter: 148.896566ms, unused: 123.295288ms 
ERRO Running error: buildssa: analysis skipped: errors in package: [main.go:169:44: cannot use process (variable of type models.Process) as *models.Process value in argument to append] 
INFO Memory: 6 samples, avg is 69.5MB, max is 69.9MB 
INFO Execution took 415.151964ms 
$ golangci-lint --version
golangci-lint has version 1.23.6 built from b9eef79 on 2020-02-10T17:54:23Z
$ go version
go version go1.14rc1 linux/amd64

@anubhabMajumdar
Copy link

I am having the same issue. Any updates? I am using golangci-lint v1.23.6 and go 1.13.

@JunliWang
Copy link

I had the same issue with v1.23.3 after my Go is upgraded from 1.13 to 1.14.
clean cache did not help.
But upgrading to v1.23.7 resolved my problem.

@zerkms
Copy link

zerkms commented Mar 6, 2020

The same issue here:

golangci-lint has version 1.23.8 built from 76a82c6 on 2020-03-04T14:29:52Z
go version go1.14 linux/amd64

@AntonStoeckl
Copy link

AntonStoeckl commented Mar 7, 2020

Same here:

$ golangci-lint run service/customer/application/CommandHandler.go
WARN [runner] Can't run linter unused: buildssa: analysis skipped: errors in package: [/home/anton/GolandProjects/go-iddd/service/customer/application/CommandHandler.go:16:17: undeclared name: ForStoringCustomerEvents /home/anton/GolandProjects/go-iddd/service/customer/application/CommandHandler.go:19:39: undeclared name: ForStoringCustomerEvents]
WARN [runner] Can't run linter goanalysis_metalinter: bodyclose: failed prerequisites: buildssa@command-line-arguments
ERRO Running error: bodyclose: failed prerequisites: buildssa@command-line-arguments

Cache clean did not help.
Tried v1.23.6, v1.23.7, v1.23.8 with Go version 1.13.8 and v1.23.7, v1.23.8 with Go version 1.14

The "undeclared name" ForStoringCustomerEvents is an interface in the same package.

@diegoholiveira
Copy link

diegoholiveira commented Mar 16, 2020

I solve this issue running this command before run the golangci-lint: go list -e -compiled -test=true -export=false -deps=true -find=false -tags= -- ./... > /dev/null

'go list' needs to be executed before staticcheck to pre populate the modules cache.

@gaurav-dalvi
Copy link

i am getting same error for v1.24.0 as well. Any pointers?

@ernado
Copy link
Member

ernado commented Mar 25, 2020

@gaurav-dalvi can you please provide a log?
Now it should contain details with actual reason.

@gaurav-dalvi
Copy link

@ernado :

level=warning msg="[runner] Can't run linter goanalysis_metalinter: SA1018: failed prerequisites: 

@gaurav-dalvi
Copy link

things are passin for me now with 1.23.8 but for sure 1.24.0 was giving above problem

@tschaub
Copy link

tschaub commented Mar 25, 2020

I'm using golangci-lint via the Go extension for VSCode. I think I'm seeing the same issue that others are, but am uncertain if there are other tools used by the extension that are complicating the problem. Apologies if this is not the same issue as above.

I'm running [email protected]. Below are the steps to reproduce and the output from golangci-lint.

mkdir example && cd example && go mod init example.com/pkg/example
touch main.go
code .

In VSCode, I paste the following (without imports) into main.go:

package main

type Soup struct {
	Chicken bool
}

var _ json.Marshaler = (*Soup)(nil)

func (soup *Soup) MarshalJSON() ([]byte, error) {
	if soup.Chicken {
		return []byte(`"yum!"`), nil
	}
	return []byte(`"meh"`), nil
}

func main() {
	soup := &Soup{}
	data, err := json.Marshal(soup)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("soup: %s\n", string(data))
}

I see this output from the Go extension:

Starting linting the current package at /Users/tschaub/projects/example
Error while running tool: /Users/tschaub/go/bin/golangci-lint run --print-issued-lines=false
level=warning msg="[runner] Can't run linter goanalysis_metalinter: assign: failed prerequisites: [[email protected]/pkg/example: analysis skipped: errors in package: [/Users/tschaub/projects/example/main.go:7:7: undeclared name: json /Users/tschaub/projects/example/main.go:18:15: undeclared name: json /Users/tschaub/projects/example/main.go:20:3: undeclared name: log /Users/tschaub/projects/example/main.go:22:2: undeclared name: fmt]]"
level=warning msg="[runner] Can't run linter unused: buildir: analysis skipped: errors in package: [/Users/tschaub/projects/example/main.go:7:7: undeclared name: json /Users/tschaub/projects/example/main.go:18:15: undeclared name: json /Users/tschaub/projects/example/main.go:20:3: undeclared name: log /Users/tschaub/projects/example/main.go:22:2: undeclared name: fmt]"
level=error msg="Running error: buildir: analysis skipped: errors in package: [/Users/tschaub/projects/example/main.go:7:7: undeclared name: json /Users/tschaub/projects/example/main.go:18:15: undeclared name: json /Users/tschaub/projects/example/main.go:20:3: undeclared name: log /Users/tschaub/projects/example/main.go:22:2: undeclared name: fmt]"

After accepting the first suggested fix (import encoding/json), I see this output from the Go extension:

Starting linting the current package at /Users/tschaub/projects/example
Error while running tool: /Users/tschaub/go/bin/golangci-lint run --print-issued-lines=false
level=warning msg="[runner] Can't run linter goanalysis_metalinter: SA1025: failed prerequisites: [[email protected]/pkg/example: analysis skipped: errors in package: [/Users/tschaub/projects/example/main.go:22:3: undeclared name: log /Users/tschaub/projects/example/main.go:24:2: undeclared name: fmt]]"
level=warning msg="[runner] Can't run linter unused: buildir: analysis skipped: errors in package: [/Users/tschaub/projects/example/main.go:22:3: undeclared name: log /Users/tschaub/projects/example/main.go:24:2: undeclared name: fmt]"
level=error msg="Running error: buildir: analysis skipped: errors in package: [/Users/tschaub/projects/example/main.go:22:3: undeclared name: log /Users/tschaub/projects/example/main.go:24:2: undeclared name: fmt]"

At this point, the extension no longer works, and I see this "Your workspace is misconfigured" dialog.

image

@JuanJoseGonGi
Copy link

I'm using golangci-lint via the Go extension for VSCode. I think I'm seeing the same issue that others are, but am uncertain if there are other tools used by the extension that are complicating the problem. Apologies if this is not the same issue as above.

I'm running [email protected]. Below are the steps to reproduce and the output from golangci-lint.

mkdir example && cd example && go mod init example.com/pkg/example
touch main.go
code .

In VSCode, I paste the following (without imports) into main.go:

package main

type Soup struct {
	Chicken bool
}

var _ json.Marshaler = (*Soup)(nil)

func (soup *Soup) MarshalJSON() ([]byte, error) {
	if soup.Chicken {
		return []byte(`"yum!"`), nil
	}
	return []byte(`"meh"`), nil
}

func main() {
	soup := &Soup{}
	data, err := json.Marshal(soup)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("soup: %s\n", string(data))
}

I see this output from the Go extension:

Starting linting the current package at /Users/tschaub/projects/example
Error while running tool: /Users/tschaub/go/bin/golangci-lint run --print-issued-lines=false
level=warning msg="[runner] Can't run linter goanalysis_metalinter: assign: failed prerequisites: [[email protected]/pkg/example: analysis skipped: errors in package: [/Users/tschaub/projects/example/main.go:7:7: undeclared name: json /Users/tschaub/projects/example/main.go:18:15: undeclared name: json /Users/tschaub/projects/example/main.go:20:3: undeclared name: log /Users/tschaub/projects/example/main.go:22:2: undeclared name: fmt]]"
level=warning msg="[runner] Can't run linter unused: buildir: analysis skipped: errors in package: [/Users/tschaub/projects/example/main.go:7:7: undeclared name: json /Users/tschaub/projects/example/main.go:18:15: undeclared name: json /Users/tschaub/projects/example/main.go:20:3: undeclared name: log /Users/tschaub/projects/example/main.go:22:2: undeclared name: fmt]"
level=error msg="Running error: buildir: analysis skipped: errors in package: [/Users/tschaub/projects/example/main.go:7:7: undeclared name: json /Users/tschaub/projects/example/main.go:18:15: undeclared name: json /Users/tschaub/projects/example/main.go:20:3: undeclared name: log /Users/tschaub/projects/example/main.go:22:2: undeclared name: fmt]"

After accepting the first suggested fix (import encoding/json), I see this output from the Go extension:

Starting linting the current package at /Users/tschaub/projects/example
Error while running tool: /Users/tschaub/go/bin/golangci-lint run --print-issued-lines=false
level=warning msg="[runner] Can't run linter goanalysis_metalinter: SA1025: failed prerequisites: [[email protected]/pkg/example: analysis skipped: errors in package: [/Users/tschaub/projects/example/main.go:22:3: undeclared name: log /Users/tschaub/projects/example/main.go:24:2: undeclared name: fmt]]"
level=warning msg="[runner] Can't run linter unused: buildir: analysis skipped: errors in package: [/Users/tschaub/projects/example/main.go:22:3: undeclared name: log /Users/tschaub/projects/example/main.go:24:2: undeclared name: fmt]"
level=error msg="Running error: buildir: analysis skipped: errors in package: [/Users/tschaub/projects/example/main.go:22:3: undeclared name: log /Users/tschaub/projects/example/main.go:24:2: undeclared name: fmt]"

At this point, the extension no longer works, and I see this "Your workspace is misconfigured" dialog.

image

I have the same issues. When you change branch on git it happens and restarting the language server it works. I don't know if it is related with golangci

@youzeliang
Copy link

golangci-lint has version 1.25.0 built from 3082512 on 2020-04-22T23:03:03Z

go version go1.14 darwin/amd64

GoLand 2020.1

and I add File Watcher using existing golangci-lint template.

when I save it, it seems to report "level=warning msg="[runner] Can't run linter goanalysis_metalinter: asmdecl: analysis skipped: ".....

@ernado
Copy link
Member

ernado commented Apr 23, 2020

Hey, please provide a way to reproduce this issue.
Also don't forget to perform golangci-lint cache clean

@bacongobbler
Copy link

bacongobbler commented May 14, 2020

Hey @ernado. The simplest method to reproduce the issue is to use an older version of golangci-lint (in our case, 1.21.0) and Go 1.14. The combination results in golangci-lint run reporting a warning on a compiler error, but succeeding instead of failing (as in, golangci-lint run displays warnings, but returns exit code zero).

Updating to golangci-lint 1.27.0 fixed this for us. It likely has to do with the fact that 1.21.0 was compiled with an older version of Go, and is incompatible when building packages with Go 1.14.

A recent CI run from helm/helm shows the same error message, which uses the same golangci-lint and Go version reported:

GO111MODULE=on golangci-lint run
WARN [runner] Can't run linter unused: buildssa: analysis skipped: errors in package: [/home/circleci/helm.sh/helm/cmd/helm/require/args.go:19:2: could not import github.com/pkg/errors (/go/pkg/mod/github.com/pkg/[email protected]/errors.go:96:2: could not import fmt (/usr/local/go/src/fmt/errors.go:7:8: could not import errors (/usr/local/go/src/errors/wrap.go:8:2: could not import internal/reflectlite (/usr/local/go/src/internal/reflectlite/value.go:8:2: could not import runtime (/usr/local/go/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)))))) /home/circleci/helm.sh/helm/cmd/helm/require/args.go:20:2: could not import github.com/spf13/cobra (/go/pkg/mod/github.com/spf13/[email protected]/args.go:4:2: could not import fmt (/usr/local/go/src/fmt/errors.go:7:8: could not import errors (/usr/local/go/src/errors/wrap.go:8:2: could not import internal/reflectlite (/usr/local/go/src/internal/reflectlite/value.go:8:2: could not import runtime (/usr/local/go/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))))))] 
WARN [runner] Can't run linter goanalysis_metalinter: deadcode: analysis skipped: errors in package: [/home/circleci/helm.sh/helm/internal/version/version.go:20:2: could not import flag (/usr/local/go/src/flag/flag.go:71:2: could not import errors (/usr/local/go/src/errors/wrap.go:8:2: could not import internal/reflectlite (/usr/local/go/src/internal/reflectlite/value.go:8:2: could not import runtime (/usr/local/go/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))))) /home/circleci/helm.sh/helm/internal/version/version.go:21:2: could not import runtime (/usr/local/go/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)) /home/circleci/helm.sh/helm/internal/version/version.go:22:2: could not import strings (/usr/local/go/src/strings/builder.go:8:2: could not import unicode/utf8 (-: could not load export data: cannot import "unicode/utf8" (unknown iexport format version 1), export data is newer version - update tool))] 

While updating to a newer version of golangci-lint does indeed fix this issue, my main concern lies with the fact that an update to Go 1.14 caused golangci-lint to succeed in cases where compiling the project should've failed. It is entirely possible this may arise again in the future.

I'm wondering if there's an error case that can be captured here that should report an error rather than logging a warning.

Hope this helps.

@ernado
Copy link
Member

ernado commented May 14, 2020

Great investigation, @bacongobbler, thank you!

It is correct, older versions of golangci-lint can silently fail in such conditions :(

@ernado
Copy link
Member

ernado commented May 15, 2020

I'll close this issue for now. Feel free to open another issue if this re-occurs for version after v1.27.0.

Thanks everybody.

@ernado ernado closed this as completed May 15, 2020
xantocoder pushed a commit to xantocoder/gitaly that referenced this issue Nov 8, 2020
Because golangci-lint fails frequently because of the
issues in tool itself `retry` strategy was added.
golangci/golangci-lint#896
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cursed This issue is doomed. feedback required Requires additional feedback
Projects
None yet
Development

No branches or pull requests