Max value that can be stored in iota type in golang

Can anyone please help me to know what is the max value that can be stored in iota type

1 Like

iota is not a type but a keyword to assist in creating enumerations. Perhaps you can show an example of code that illustrates your concerns?

if i type :
const (
b = iota


out put will be 3 because iota gets incremented by 1 for every variable.
So i want to know what is the maximum value that iota can store or there is no restriction to it.

That’s an interesting question as you’re creating an untyped integer constant and those can in theory be arbitrarily large. In practice there is likely to be a limitation at the size of an integer (32/64 bits) or something larger (256 bits?). I suspect your program’s source code will exhaust all available RAM to compile before you run into the limit, though.

Thanks for your reply,
I was trying to find the description for this on
There it is mentioned that iota is untyped int constant.
May be it will have the size Int32 or Int64 based on the platform?

Maybe. You’d need at minimum 2^31 constants in your source, one per line, for that to be a problem though. At that point I suspect you will run into other problems, and that there are better ways to do whatever it is you’re doing.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.