Skip to content
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

I'm getting again and again the same "Go linter running error", why? #100

Closed
frederikhors opened this issue Feb 2, 2022 · 15 comments
Closed

Comments

@frederikhors
Copy link

frederikhors commented Feb 2, 2022

I'm getting again and again the same error in Goland:

Go linter running error
Please make sure there's no syntax error, then check if any config error

I have the below .golangci.yml file in my root dir:

linters:
  enable-all: true
  disable:
    - dupl
    - exhaustivestruct
    - gci
    - gochecknoinits
    - godox
    - gofmt
    - gofumpt
    - goimports
    - golint # deprecated
    - gomnd
    - interfacer # deprecated
    - lll
    - maligned # deprecated
    - misspell
    - nlreturn
    - promlinter
    - scopelint # deprecated
    - varnamelen

I'm using

golangci-lint has version 1.44.0 built from 617470fa on 2022-01-25T11:31:17Z

and Goland 2021.3.2 with Go Linter 1.5.9 on Windows 10.

What's the problem?

@xxpxxxxp
Copy link
Owner

xxpxxxxp commented Feb 3, 2022

Hi @frederikhors , if there's no syntax error, just run go mod tidy to sync deps it will disappear.

@frederikhors
Copy link
Author

I already did it. Nothing changes (go.mod & go.sum are updated) and it keeps to show again and again.

Is there a way to read some logs?

@xxpxxxxp
Copy link
Owner

xxpxxxxp commented Feb 4, 2022

Yes, there's Goland log, click Help - Show Log in xxx, open the log with an editor and search for go-linter
Please execute the Debug command in your terminal too, see if it could be successfully running.

@frederikhors
Copy link
Author

I tried the Debug command in my terminal and it works. I really don't know what is going on.

The command is: cd C:\project && set "PATH=C:\Program Files\Go\bin;C:\Python310\Scripts\;C:\Users\Fred\go\bin;C:\Program Files\JetBrains\GoLand 2021.3.2\bin" && set "GOPATH=C:\Users\Fred\go" && "C:\Users\Fred\go\bin\golangci-lint.exe" "run" "--out-format" "json" "--allow-parallel-runners" "-j" "6" "--max-issues-per-linter" "0" "--max-same-issues" "0" "-c" "C:\project\.golangci.yml"

Or maybe the problem is:

level=error msg="Running error: 1 error occurred:\n\t* can't run linter goanalysis_metalinter: inspect: failed to load package dataloaders: could not load export data: no export data for \"project/pkg/project/graphql/dataloaders\"\n\n"
. Please make sure the project has no syntax error. 

@xxpxxxxp
Copy link
Owner

xxpxxxxp commented Feb 5, 2022

can't run linter goanalysis_metalinter: inspect: failed to load package dataloaders: could not load export data: no export data for "project/pkg/project/graphql/dataloaders" this is the error that golangci-lint returns when the plugin tried to execute it. While it seems the debug cmd worked in your terminal, it might related to env variables, is it possible to share me a minimized reproducible project for me to inspect?

@frederikhors
Copy link
Author

I found this: golangci/golangci-lint#2523 and golangci/golangci-lint#1920.

I clearead my go.mod and go.sum and recreated them: THE ERROR IS STILL THERE.

If I simply run golangci-lint run in the root directory this error is not there!

I cannot share code right now because the project is big and private.

@frederikhors
Copy link
Author

I just found this too: https://youtrack.jetbrains.com/issue/GO-11249.

@xxpxxxxp
Copy link
Owner

xxpxxxxp commented Feb 6, 2022

With those 2 still no luck?

$ go clean -modcache
$ go mod tidy

As mentioned in those related issues, it might due to inconsistent env variables between your terminal and Goland, would you share your go env output?

@frederikhors
Copy link
Author

Yeah, still no luck after those 2 commands. I tried it very precisely. The go.sum changed but still the crazy error.

  • go env:
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Fred\AppData\Local\go-build
set GOENV=C:\Users\Fred\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\Fred\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\Fred\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.17.6
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=NUL
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\Fred\AppData\Local\Temp\go-build1102088622=/tmp/go-build -gno-record-gcc-switches

@xxpxxxxp
Copy link
Owner

xxpxxxxp commented Feb 8, 2022

2 questions,

  • Do you have 2 go each install at C:\Program Files\Go\bin and C:\Users\Fred\go\bin?
  • go env above is from terminal, but it seems GO111MODULE is off. Your project is using go module right?

@mkevac
Copy link

mkevac commented Feb 9, 2022

I had the same problem for soooo long and today I've decided to look into it.
This is what I saw in Help -> Show logs in Finder

2022-02-09 19:31:57,150 [11251100]   WARN -                      go-linter - Run error: level=warning msg="Failed to discover go env: failed to run 'go env': exit status 1"
level=error msg="Running error: context loading failed: failed to load packages: failed to load with go/packages: err: exit status 1: stderr: missing $GOPATH\n"
. Please make sure the project has no syntax error. 
2022-02-09 19:31:57,150 [11251100]   WARN -                      go-linter - Debug command: cd /Users/marko/bumble/src/go/core && export PATH=/Users/marko/go/bin:/usr/bin:/bin:/usr/sbin:/sbin && export GOPATH= && '/Users/marko/bin/golangci-lint' 'run' '--out-format' 'json' '--allow-parallel-runners' '-j' '2' '--max-issues-per-linter' '0' '--max-same-issues' '0' '--no-config' '--disable-all' '-E' 'staticcheck,interfacer,exportloopref,govet,dupl,funlen,errorlint,gocritic,goconst,gocognit,ineffassign,bodyclose,gosec,maligned,unconvert,revive,stylecheck,whitespace,goprintffuncname,gosimple,prealloc,gocyclo' '.' 

It was strange, because there is a GOPATH set

image

Just for LOLs I added it one more time

image

And now everything works...

I consider this a bug, but as a workaround it is fine :-)

@xxpxxxxp
Copy link
Owner

Hi @mkevac , that was unusual, does restarting Goland help resolve the issue? I mean after remove the one you added.

@mkevac
Copy link

mkevac commented Feb 12, 2022

@xxpxxxxp it does not. As soon as I remove added line, error comes back.

@xxpxxxxp
Copy link
Owner

@mkevac I've created a new issue #102
Please help me with some details if convenient to you.

@MakeMeLaugh
Copy link

The original (goanalysis_metalinter) error and one that @mkevac discovered workaround for (empty GOPATH) may not be related, tbh.

I've found another use case which can cause almost the same outcome:

The example value for the run.issues-exit-code param was changed in the .golangci.example.yml file during this PR.

If you (as I've done) copy this file to your project to clean it up and configure it for your needs not relying on the default parameters you may end up getting constant go-linter - Run error: . Please make sure the project has no syntax error. error because the plugin only treats exit codes of 0 and 1 as "good" exit codes (this part in particular).

Changing run.issues-exit-code value back to 1 in project's .golangci.yaml file fixed the issue for me.

Just to be clear: if I'm not mistaken, the default value for run.issues-exit-code is still 1 in golangci-lint if none is specified in custom config file. The change was made only to the example config file.

@xxpxxxxp xxpxxxxp closed this as completed Apr 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants