go iota

package main

import "fmt"

const (
	a = iota
	b = iota
)
const (
	name = "menglu"
	c    = iota
	d    = iota
)

func main() {
	fmt.Println(a)
	fmt.Println(b)
	fmt.Println(c)
	fmt.Println(d)
}

  

输出 还以为是 01 01 没想到

╭─mac@macdeMacBook-Pro ~/www/go/im ‹master*›
╰─$ go run main.go
0
1
1
2

posted @ 2021-09-13 22:22  brady-wang  阅读(94)  评论(0编辑  收藏  举报