Golang, a strong-typed language allows the ability to group constants together in parenthesis with the iota
keyword. But coupling that with a string representation can add extra boilerplate code. Let’s first take a look at how constants and enums are created in Go.
A recap on constants and enums in Go…
For example, as constants by placing them in parenthesis:
const ( Dog = 0 Cat = 1 Bird = 2 )
Using the iota
keyword to make an enum:
const ( Dog = iota Cat Bird