- No enums
- No variant types
No enums
You can define something like an enum this way. The problem is that it’s fake: you don’t get any benefits of typing, though it seems like you should.
type EnumThing int
const (
A EnumThing = iota
B
)
func foo(e EnumThing) {
}
You can pass -42 to foo and the compiler won’t complain. There is no easy way around this. i haven’t found a place where the design decision is explained.
No variant types
The reasoning is given here and I guess I’ll have to learn about interfaces before I can say if that’s justified. For now, yes, I miss variant types, just as I miss enums.