I think it'd make more sense to just make a idiomatic struct:
type Genre struct {
id int
name string
}
func New(id int, name string) Genre {
return Genre {id, name}
}
Then, you can define your categories normally: var (
Adventure = genre.New(1, "Adventure")
Comic = genre.New(2, "Comic")
// etc
)
And have a O(1) String() method that doesn't need to be edited every time a new category gets added/removed/changed: func (g Genre) String() string {
return g.name
}
You can also change the implementation of the type without breaking consumers (e.g. maybe you want a pointer to a struct instead of a struct)This also means that you don't accidentally leak an "is-a" relationship between the nominal type and the underlying implementation type
var foo Genre = Adventure
foo + 1 // ought to throw a compilation error!