Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一组常量:
const ( a = 100 b = 200 c = 300 )
我想知道是否有任何方法可以使用iota关键字而不是手动分配每个值?
iota
如官方参考中所述,可以使用 iota 的按位移位来增加数字,但我想增加一个固定的数字,例如 100。
const ( _ = iota * 100 a b c )
https://play.golang.org/p/V-2Uv9JPj6g