package main
import (
"fmt"
)
const (
a = iota
b = iota
c = iota
)
const (
e, f, g = iota, iota, iota
)
func main() {
fmt.Println(a, b, c)
fmt.Println(e, f, g)
}
在Go中使用另一个常量iota计数器,只能在常量的表达式中使用。 iota在const关键字出现时将被重置为0(const内部的第一行之前),const中
每新增一行常量声明将使iota计数一次(iota可理解为const语句块中的行索引)。使用iota能简化定义,在定义枚举时很有用。