iota makes it easy to declare sequentially growing numeric constants:

https://codeeval.dev/gist/819d209619b595557942a06facb506f7

iota sets the value of Low to 0 and instructs the compiler that the following constants have increasing numeric values.

Creating bitmask values with iota

Iota can be very useful when creating a bitmask. For instance, to represent the state of a network connection which may be secure, authenticated, and/or ready, we might create a bitmask like the following:

https://codeeval.dev/gist/67206141b4b2985a6df7be09c2bfb031

Skipping values

The value of iota is still incremented for every entry in a constant list even if iota is not used:

https://codeeval.dev/gist/b52473024d89db16329ca485584db867

It will also be incremented even if no constant is created at all, meaning the empty identifier can be used to skip values entirely:

https://codeeval.dev/gist/fff5fb28ddfa5b3da361c3d06146bad1

Using iota in an expression list

Because iota is incremented after each [ConstSpec](<https://golang.org/ref/spec#ConstSpec>), values within the same expression list will have the same value for iota:

https://codeeval.dev/gist/4c56666f684275ae882dc898e1b9269d

Using iota in an expression

iota can be used in expressions, so it can also be used to assign values other than simple incrementing integers starting from zero. To create constants for SI units, use this example from Effective Go:

https://codeeval.dev/gist/99cf2064143a2ba6c300eaede546c536