Hi,
I know that golang doesn't have enums but use the constants and iota to simulate it.
What I feel missing and still haven't figured out is that, in C, enums and variables are associated. I.e., when associate a variable with enum values, we know for sure that such variable will take no values other than the ones from defined enums. What's the best way to establish such association in go?
For example, can I define a groups of constants like the following, and express the idea that my variable myWeekDay takes nothing but the such constants? I know it might be hard to enforce it, so I think establishing such logical association is more important.
Thanks
const (
Sunday = iota
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
numberOfDays // this constant is not exported
)