这篇文章将为大家详细讲解有关golang中iota怎么用,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。
可能大家都在const中定义过原子数。const自带一个原子性自增的关键字iota
package main
import "fmt"
func main() {
const name = "BeinMenChuiXue"
fmt.Println(name)
const (
homeAddr = "earth"
nickName = "WeiLaiShiXuePai"
)
fmt.Println(homeAddr, nickName)
const (
zero = iota
one
two = iota
three
)
fmt.Println(zero, one, two, three)
const (
first = iota
second
)
fmt.Println(first, second)
const (
student = "Golang"
teacher
parents = "S"
children
)
fmt.Println(student, teacher, parents, children)
}
关于“golang中iota怎么用”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。