Enums in Go
I was asked yesterday how you implement enums in Go. I didn’t know, so I spent some time this morning learning how to do it. It turns out this is ridiculously easy to do and Go has the stringer tool which makes it super simple. (stringer codegens the code which prints your enum as a string.) Example I created a repo with the following structure: go.mod main.go internal/coffee/coffee.go internal/coffee/coffee_string.go internal/coffee/coffee.go looks like this:...