DEV Community

Discussion on: Enums in Go - why and how?

Collapse
 
andreybronin profile image
Andrey Bronin

Guys from Uber recommends to start enum from 1, zero is default(not initialized) value, in this case, you no need "unknown" value

github.com/uber-go/guide/blob/mast...

Collapse
 
ineedale profile image
Alex Leonhardt • Edited

Thanks! That's actually a good point, although there are valid cases for starting at 0.

Thinking about it, defaulting to 0 in the example case above is probably actually a valid thing to do.

Nevertheless, thanks for the link and tip! I'll have a read through what Uber does and try to learn from them too.