GoLand 2024.1 Help

Code Inspections in Go modules

This topic lists all GoLand code inspections available in Go modules.

You can toggle specific inspections or change their severity level on the Editor | Inspections page of the IDE settingsĀ  Ctrl+Alt+S.




Default Severity

Migration to Go workspace is possible

Generates 'go.work' files using 'replace' directives.

Go workspaces is a feature introduced in Go 1.18 that allows working simultaneously on several modules.
Workspaces are a modern alternative to 'replace' directives pointing to local directories.
All modules in a workspace have the same set of dependencies, thus making the configuration simpler, more robust, and requiring fewer 'go list' calls to scan the project structure.
The fix for this inspection generates a new 'go.work' file and does not change existing files.

By default, the 'warning' severity is used. If a generated workspace would include Go modules that were not replaced in the original 'go.mod', no warning is shown due to possible side effects caused by migration. But you can still run the fix manually.

For more information about workspaces, refer to Go Modules Reference.
For Go workspaces introduction, see Tutorial: Getting started with multi-module workspaces.

Warning Warning

Declaration redundancy



Default Severity

Unused dependency

Reports unused dependencies.

For each dependency in the current go.mod file, this inspection searches for any import statement starting with the dependency name in all GO files. If no such imports found then the dependency is considered unused. This inspection is an equivalent of the go mod why command.

The inspection processes require and replace directives. The require directives with // indirect comments are also processed.

The inspection might not accurately determine that a replaced or indirectly-required dependency is unused in the following cases:

  • Vendoring mode is enabled

  • Some dependencies are not downloaded

Warning Warning

Last modified: 15 April 2024