Inspectopedia
 
2024.3

Irregular usage of 'iota'

Info
Code Style
New
Last modified: 03 December 2024

Reports irregular usage of iota within a constant declaration.

The iota identifier is reset for every constant declaration and automatically incremented for every constant specification. Within one constant specification, the identifier keeps its value. Explicitly referring to iota does not reset the counter.

For more information, refer to Iota in the Go specification.

This inspection is triggered if two constant specifications have a textually identical expression list containing at least one reference to iota and there are exclusively constant specifications without an expression list in between them.

Consider omitting the redundant expression list or writing out the expression list every time.

Example:

Triggers the inspection as the iota in the definition of c is redundant.

Example:

Does not trigger the inspection as none of the expression lists is redundant.