Go Use of iota in an expression list


Example

Because iota is incremented after each ConstSpec, values within the same expression list will have the same value for iota:

const (
    bit0, mask0 = 1 << iota, 1<<iota - 1  // bit0 == 1, mask0 == 0
    bit1, mask1                           // bit1 == 2, mask1 == 1
    _, _                                  // skips iota == 2
    bit3, mask3                           // bit3 == 8, mask3 == 7
)

This example was taken from the Go Spec (CC-BY 3.0).