go-iota-usage
keyword iota
is used on const enum, it defines the auto-incremental counter starting from 0
for ex
1 | const ( |
another example
1 | const ( |
run it, you would see result as this :
1 | 1024 |
in a single const enum, you could provide multiple iota, each of them would increase independtly
1 | const ( |
result :
1 | 0 |
if iota
auto-increment is interrupted, you have to explicitly restore it
1 | const ( |
how iota
got applied into the const enum, the pesudo code is as such :
1 | for iota, spec := range ValueSpecs { |
from this code we can see that, even iota
appears multiple times in a single line, it won’t auto-increment