Closed kpvt001 closed 1 year ago
Hi @kpvt001 , please paste the error log here for debugging, you can find it in Goland or Intellij by clicking
Hi @kpvt001 ,请找一下error日志贴到这里来辅助找问题,可以在你的IDE里依此点:
Help
-> Show Log in ...
-> open the log file, search for go-linter
Ran into the same error, not sure where it's looking but I have a project open in IntelliJ that is one level above all my projects (I've worked this way for years).
<pathx>
<project1>
<project2>
<project3>
...
Is this plugin looking for the .go files to be directly in the project?
2023-07-05 07:29:49,624 [1419871] WARN - go-linter - Run error: level=error msg="Running error: context loading failed: no go files to analyze" . Please make sure the project has no syntax error.
Hi @gcstang , the plugin has several different working modes, each needing corresponding setting. The out-of-box config is working for single project as you mentioned.
For your case, you can follow I have multiple Go sub-projects in the root project
:
Uncheck Project Root. Be aware that only the config file directly under the project root will be used.
Ref: https://github.com/xxpxxxxp/intellij-plugin-golangci-lint#setting-guide
Now I see this error, does the plugin UI not work when using this configuration and I have to create a config file manually?
2023-07-06 07:19:35,384 [ 533413] WARN - go-linter - Run error: level=error msg="Running error: context loading failed: no go files to analyze" . Please make sure the project has no syntax error.
@gcstang sorry I'm confused, it's still the same error as before? Would you paste the content of <your project path>/.idea/golinter.xml
here for me to debug.
@gcstang sorry I'm confused, it's still the same error as before? Would you paste the content of
<your project path>/.idea/golinter.xml
here for me to debug.
`<?xml version="1.0" encoding="UTF-8"?>
@gcstang sorry for the late reply, in the log where you find such log, there's also a following line that prints a debug command, would you paste that line too
2023-07-06 07:19:35,384 [ 533413] WARN - go-linter - Run error: level=error msg="Running error: context loading failed: no go files to analyze"
. Please make sure the project has no syntax error.
@gcstang sorry for the late reply, in the log where you find such log, there's also a following line that prints a debug command, would you paste that line too
2023-07-06 07:19:35,384 [ 533413] WARN - go-linter - Run error: level=error msg="Running error: context loading failed: no go files to analyze" . Please make sure the project has no syntax error.
2023-07-11 07:29:13,110 [ 207849] WARN - go-linter - Debug command: cd '/Users/myuser/dev/GoLang/src/github.com/example-goproject/cmd/example-goproject' && export PATH='/Users/myuser/go/bin:/usr/bin:/bin:/usr/sbin:/sbin' && export GOPATH='' && export GO111MODULE='on' && '/Users/myuser/dev/GoLang/bin/golangci-lint' 'run' '--out-format' 'json' '--allow-parallel-runners' '-j' '2' '--issues-exit-code' '1' '--max-issues-per-linter' '0' '--max-same-issues' '0' '--no-config' '--disable-all' '-E' 'exportloopref,predeclared,funlen,gocritic,goconst,reassign,sqlclosecheck,gocognit,ineffassign,revive,prealloc,staticcheck,interfacer,govet,dupl,errorlint,misspell,gochecknoinits,nosprintfhostport,makezero,bodyclose,gosec,maligned,godox,unconvert,stylecheck,whitespace,goprintffuncname,gosimple,goimports,gocyclo,gocheckcompilerdirectives' '--build-tags' 'unix' '.'
Thanks @gcstang ! I'm suspecting the empty GOPATH, or the build tag is causing the issue. Would you try run the debug command in a terminal, see if any output, and try without export GOPATH=''
, also try without '--build-tags' 'unix'
Thanks @gcstang ! I'm suspecting the empty GOPATH, or the build tag is causing the issue. Would you try run the debug command in a terminal, see if any output, and try without
export GOPATH=''
, also try without'--build-tags' 'unix'
My GOPATH is not empty; in IntelliJ it's configured (checkbox) to "Use GOPATH that's defined in system environment"
This works correctly using the DEBUG line from a iTerm terminal.
You mean when try run the command without export GOPATH=''
, it works fine?
It's a known issue sometimes the plugin cannot pickup environment variables of system, especially when it's defined in 3rd party terminal (.zshrc etc). I'll see what I can do to workaround.
For now, a simple fix could be adding the same global GOPATH to Project GOPATH in settings like below
It will not impact IDE behavior but make the plugin happy
Copying the path works for now. Is there something that provides more meaning for the Problems found within the UI? i.e. ineffectual assignment to val
glad it works. For the hint text, it's from the underlying linters: https://golangci-lint.run/usage/linters/ Unless they provide more info, there's nothing the plugin can do.
Please make sure no syntax or config error, then run 'go mod tidy' to ensure deps ok.
Running
go build .
orgo vet ./...
working fine.Each project use different goland instance.
Already set go path to .zshrc file.