Configuring golangci-lint
Important Information
If you encounter warnings:
Ensure there are no syntax or configuration issues.
Run
go mod tidy
to refresh dependencies.
How to Use
After installing the plugin, you will see a popup when the IDE starts. If the popup dialog did not appear, open the settings manually by pressing Ctrl+Alt+S. The path to the Go Linter settings is .
The plugin requires a golangci-lint executable. If the golangci-lint is not installed, follow the installation guide at golangci-lint .run to install it.
In the IDE settings, you can use on of the following configuration options:
Choose one :select the executable from the dropdown if it is already available in your
PATH
.Open...: select an executable from your disk.
Get Latest :download the latest version from GitHub.
If you have a
.golangci.json
,.golangci.toml
,.golangci.yaml
, or.golangci.yml
configuration file, the plugin will automatically detect and use it. Otherwise, select the linters you need.Click OK.
Settings Guide
I have a Go project as the root project: use the default settings.
I am using IntelliJ Ultimate with a Go project nested in a sub-directory: set Project Root to the Go project path.
I have multiple Go sub-projects in the root project: uncheck Project Root. Only the configuration file located directly under the project root will be used.
I want to use a configuration file that is not under the root project:
Set Using config to the desired configuration file.
WSL
Ensure GOROOT is set in the IDE before configuring the plugin settings.
If you encounter a type-check error despite a successful
go build
, installgcc
in WSL:# Ubuntu/Debian sudo apt install build-essential # Arch/Manjaro sudo pacman -S gcc # Red Hat/Fedora/CentOS sudo yum groupinstall 'Development Tools' # or with dnf sudo dnf groupinstall 'Development Tools'
For Windows Users
Disable
goimports
,gofmt
, andgci
linters. Instead, use GoLand or a file watcher for code formatting.If you still want to use these linters, download GNU diff and GNU LibIconv, and add them to your system
PATH
(for example,C:\WINDOWS
).