Configuring golangci-lint
This functionality relies on the Go Linter plugin, which is bundled and enabled in GoLand by default. If the relevant features are not available, make sure that you did not disable the plugin.
Press to open settings and then select Plugins.
Open the Installed tab, find the Go Linter plugin, and select the checkbox next to the plugin name.
If you encounter warnings:
Ensure there are no syntax or configuration issues.
Run
go mod tidy
to refresh dependencies.
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 . The path to the Go Linter settings is Settings | Tools | Go Linter.
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.
note
golangci-lint is a linter tool and works only if your project builds successfully. Otherwise, it will report no issues.
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.
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'
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
).