GoLand 2024.3 Help

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

  1. 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 Settings | Tools | Go Linter.

  2. 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.

  3. 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.

  4. 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, install gcc 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, and gci 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).

Last modified: 10 October 2024