GoLand 2023.3 Help

Code inspections

In GoLand, there is a set of code inspections that detect and correct abnormal 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 dialog (Control+Alt+S), go to Editor | Inspections.

    You can also press Control+Alt+Shift+H and select Configure Inspections in the popup that opens.

    The list of inspections and their settings

Use the Filter icon to filter the inspection list. For example, you can filter inspections by severity or by language.

Code inspections with Qodana

Install the Qodana plugin

This functionality relies on the Qodana plugin, which you need to install and enable.

  1. Press Control+Alt+S to open the IDE settings and then select Plugins.

  2. Open the Marketplace tab, find the Qodana plugin, and click Install (restart the IDE if prompted).

On top of running code inspections in your IDE, you can inspect your code using Qodana:

  • Run GoLand inspections locally including your IDE, and as a part of CI/CD pipelines.

  • Run resource-consuming inspections using your CI/CD infrastructure.

  • Enforce quality standards with quality gates in your CI system.

  • Share the same inspection profile, both within the IDE and the CI tool.

  • Access inspections that are available only in Qodana, such as security checks and license audits.

  • Access historical overviews of inspection results

    You can compare inspection results between commits to better understand your progress.

For more information, refer to Qodana.

Qodana report

Examples of code inspections

To see the list of available inspections, open settings Control+Alt+S and navigate to Editor | Inspections.

Unreachable code

The Unreachable code inspection detects parts of code that cannot be executed.

The unreachable code inspection

Unhandled Error

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.

The Unhandled Error code inspection

Redundant type conversions

The Redundant type conversions inspection warns you about redundant type conversions that can be omitted. Consider the following code example.

s := string("") _ = s

Code converts a string literal to a string. It is a redundant action because the output is a string anyway.

Redundant type conversions
Last modified: 11 January 2024