In go you can write an enum like this
type Direction int
const (
North Direction = iota
South
East
West
)
func main() {
// Declaring a variable myDirection with type Direction
var myDirection Direction
myDirection = West
if (myDirection == West) {
fmt.Println("myDirection is West:", myDirection)
}
}
Now image you write an enum which not only has 4 option, but instead 100. What I want is an enum that gives me "Inellisence support": If I type the enum, type a ., I want to know what options are there for the enum.
An example how this could look like is this. Is there a better way?
type direction struct{}
func (d *direction) north() string {
return "north"
}
func (d *direction) east() string {
return "east"
}
func (d *direction) south() string {
return "south"
}
func (d *direction) west() string {
return "west"
}
func main() {
var d direction
d.east()
...
}