In GoLand, there is a set of code inspections that detect and correct anomalous code in your project before you compile it. The IDE can find and highlight various problems, locate dead code, find probable bugs, spelling problems, and improve the overall code structure.
Inspections can scan your code in all project files, or only in specific scopes (for example, only in production code, or in modified files).
Every inspection has a severity level — the extent to which a problem can affect your code. Severities are highlighted differently in the editor so that you can quickly distinguish between critical problems and less important things. GoLand comes with a set of predefined severity levels, and enables you to create your own.
Inspections and their settings are grouped in profiles. Each profile contains the information on the enabled inspections, a scope of files that they analyze, and their severity levels.
Access all available inspections and their settings
In the Settings/Preferences dialog (Ctrl+Alt+S), go to .
You can also click (Ctrl+Shift+Alt+H) in the status bar (bottom right-hand corner of the editor), and click Configure inspections.
Use to filter the inspections list. For example, you can filter inspections by severity or by language.
Examples of code inspections
To see the list of available inspections, open Settings | Preferences (Ctrl+Alt+S) and navigate to .
The Unreachable code inspection detects parts of code that cannot be executed.
The Unhandled Error code inspection alerts you about functions or methods that can return an error value that is not handled in the code. In settings, you can change the severity level for each scope and, if necessary, exclude function names or method names for this inspection.
Reports problems caused by incorrect use of the
nil value. Analyses data flow to determine if variables have
nil or not
nil values. For example, with the nilness analyzer you can catch the following situations:
Method calls with
nilreceiver that could lead to nil pointer dereference.
Indexing of the
nilslice that might cause panics.
v == nilthat are meaningless if
Operations with values that are used without proper error handling. For example, in statements like
f, err := foo(), GoLand highlights potentially dangerous operations with
erris not handled.