See this program as an example:
package main
import "fmt"
const (
a = iota
b
c
iota = 0
d
e
f
)
func main() {
fmt.Printf("%v, %v, %v, %v, %v, %v \n", a, b, c, d, e, f)
}
This program outputs 0,0,0,0,0,0 since all references to iota resolve to the iota constant defined inline.
If you mean to reset or offset builtin.iota, either start a new constant definition or use
an expression involving iota as the constant value. For example:
package main
import "fmt"
const (
a = iota
b
c
)
const (
d = iota + 42
e
f
)
func main() {
fmt.Printf("%v, %v, %v, %v, %v, %v \n", a, b, c, d, e, f)
}
This program outputs 0,1,2,42,43,44 as builtin.iota is reset at the beginning of a new constant declaration and then
the offset of 42 is applied to the last three constant specifications.