If you've encountered such error:
Or, in previous version, telling you that
GOROOT is not set
It's caused by an upstreaming bug of gocritic
:
go-critic/go-critic#1157
go-critic/go-critic#1126
Please temporarily disable gocritic
linter until a new version of golangci-lint released
In case you are stuck by the dialog and cannot unselect gocritic
, please manually remove property go-enabled-linters
from file:
Win: %APPDATA%\JetBrains\Goland2021.3\options\other.xml
Mac: ~/Library/Application Support/JetBrains/Goland2021.3/options/other.xml
Linux: ~/.config/JetBrains/Goland2021.3/options/other.xml
For config file users, please disable gocritic in your config file directly
Then the settings will be working
======
Write code, write better code
All credit goes to GolangCI-Lint authors.
After the plugin installed, you will see a popup on IDEA startup, otherwise please go to settings manually:
A golangci-lint executable is required. Choose one from combobox if you already have it in your PATH, or Open...
select one from disk, or Get Latest
download one from Github release.
If you have your own .golangci.json
|.golangci.toml
|.golangci.yaml
|.golangci.yml
config file, the plugin will detect and use it.
Otherwise, select linters you need:
Click OK
, you are all set!
Please keep in mind that golangci-lint is a linter tool, it only works if your project could build (no syntax error), or it will report no issue.
- I have a Go project as root project
The default setting works perfectly - I'm using Intellij Ultimate, I have a Go project nested in sub-dir
SelectProject Root
to the Go project path - I have multiple Go sub-projects in the root project
UncheckProject Root
. Be aware that only the config file directly under the root project will be used. - I want to use a config file not under root project
SelectUsing config:
to the config file
Please disable goimports / gofmt / gci linters. Use File-Watcher in IDEA.
If you insist using those 3 linters, download GNU diff & GNU LibIconv and put them in system PATH (eg: C:\WINDOWS). Normally it's missing from the system.
- Please note down your platform (Win/Linux/Mac), IDEA/Goland version, Go version
- If the plugin reports an error, please copy-paste the error content
- Code quality improvement