在const声明中,如果使用的是按组声明const常量,那么:


const (
    o = 1;
    q
    r
    s = 'a'
    t = false
    p = iota
)
fmt.Println(o) // 输出 1
fmt.Println(q) // 输出 1
fmt.Println(r) // 输出 1
fmt.Println(s) // 输出 a
fmt.Println(t) // 输出 false
fmt.Println(p) // 输出 5

如果使用的单个const声明的常量,


const x = ‘a’
const y = false
const z = iota
fmt.Println(z) // 输出 0

从这点儿看,iota在不同的声明方式下,值也是不同的