itoa使用

问题来源

go-fuse中,使用独立的二进制bit指代不同的类型

解释

举例说明

const (
	c = 10
	d = iota
	e
	f = "hello"
	g
	h = iota
	i
	j = 0
	k
	l, m = iota, iota
	n, o
	p = iota + 1
	q
	_
	r = iota * iota
	s
	t = r
	u
	v = 1 << iota
	w
	x = iota * 0.01
	y float32 = iota * 0.01
	z
)

替换原则

  • 不同的const语句块互不干扰
  • 注释和空行 忽略,但_不能忽略
  • 没有表达式的常量定义复用上一行的表达式
  • 从第一行开始,iota 从 0 逐行加1
const (
	c = 10 // iota = 0
	d = iota // iota = 1
	e = iota // iota = 2
	f = "hello" // iota = 3
	g = "hello" // iota = 4
	h = iota // iota = 5
	i = iota // iota = 6
	j = 0 // iota = 7
	k = 0 // iota = 8
	l, m = iota, iota // iota = 9
	n, o = iota, iota // iota = 10
	p = iota + 1 // iota = 11
	q = iota + 1 // iota = 12
	_ = iota + 1 // iota = 13, 注意
	r = iota * iota // iota = 14
	s = iota * iota // iota = 15
	t = r // iota = 16
	u = r // iota = 17
	v = 1 << iota // iota = 18
	w = 1 << iota // iota = 19
	x = iota * 0.01 // iota = 20
	y float32 = iota * 0.01 // iota = 21
	z float32 = iota * 0.01 // iota = 22
)

然后每行替换iota的值即可。

posted @ 2024-03-27 16:53  LdreamerD  阅读(33)  评论(0)    收藏  举报