Inspectopedia 2025.2 Help

Missing 'case' statements for 'iota' consts in 'switch'

Reports unhandled values in switch statements when the iota identifier is in the const declaration. To handle these values, consider using case or default clauses.

The iota keyword in Go creates a sequence of integers in a const block. Although the Go compiler does not require handling all iota values, missing some of them could indicate a bug.

For more information about iota, refer to Iota at go.dev.

Examples:

const ( a = iota b c = -5 ) func main() { v := 5 switch v { case a: break; case b: break; } }

Locating this inspection

By ID

Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.

GoSwitchMissingCasesForIotaConsts
Via Settings dialog

Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.

Settings or Preferences | Editor | Inspections | Go | Probable bugs

The IDE triggers an inspection because c is not handled by the switch statement. Note that c is in the same const block even if it does not use iota.

Quick-fix options are Create 'case' clause for values and Create 'default' clause. After the Create 'default' clause quick-fix is applied:

const ( a = iota b c ) func main() { v := 5 switch v { case a: break; default: } }

Inspection ID: GoSwitchMissingCasesForIotaConsts

Suppressing Inspection

You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:

//noinspection GoSwitchMissingCasesForIotaConsts

More detailed instructions as well as other ways and options that you have can be found in the product documentation:

Inspection Details

By default bundled with:

GoLand 2025.2, Qodana for Go 2025.2,

Can be installed with plugin:

Go, 252.26654.0

Last modified: 18 September 2025