Enumerations

An enumeration allows you to declare a collection of well-known values for your package.

type Status int

const (
    NotStarted Status = iota
    Started
    Finished
)

//go:generate stringer -type=Status

The comment you see gives a nice way to print the Status value as a string while actually storing the value as an integer.

Last updated