iota

A Go keyword usable only inside a const block, where it counts 0, 1, 2 and so on, used to number a set of related constants.

In more detail

Go has no separate enum keyword; a named type plus a const block with iota does that job. Putting the unknown state first makes the zero value mean unknown, which is the safe default.

Example

const (
	unknown state = iota
	healthy
	degraded
	down
)

Related terms

Taught in

References