Hacker News new | ask | show | jobs
by khazhoux 844 days ago
The article is about enums, which are lacking in Go.
1 comments

No, Go definitely has enums. It is sum types (that some people have recently started calling enums) that Go lacks.
Go does not model enums as separate types (like e.g. Pascal), they are essentially just integers like C.
No, Go enums are definitely separate types. Sure, technically there is also an integer (or some other base representation) hidden in there somewhere, but that's what an enumeration is. Without that you don't have an enum.
Creating new types wrapping int is not really the same thing. It's not a closed set. Presumably one could define additional overlapping constants with the same integer type elsewhere?
Go types do not support value constraints, no. That has nothing to do with enums, though. That's a different feature altogether.
It has a lot to do with enums, especially if you are claiming statically typed enums. When defining a type, more often than not, we want to define the values that make up the set. For example, 'type boolean = true | false'