1. 2

Go enums and iota — Full of tips and tricks with runnable code examples.

  • What is an Enum?
  • Why do we need enums?
  • How can you imitate an enum in Go?
  • Creating enum strings automatically
  • How to use iota?
  • Iota expressions rules with examples
  • Iota insights
  1.  

  2. 1

    The problem with the example implementation of String() is that it needs to be kept in sync with the set of values in the enum type.

    1. 2

      I don’t know if this was updated after your post, but he does introduce the stringer tool. Which I realize is a little ridiculous as a language tool, but thought I’d point it out.

      1. 1

        No, Stringer recommendation was there.

        In the post, first I’m trying to explain how enums work rather than the best practices. Then, I widening it more about what to use for enums. Including stringer and iota.