How to Create Enums in Go (iota Patterns)

Use the iota keyword inside a const block to automatically generate sequential integer values for Go enum constants.

Use iota inside a const block to generate a sequence of integer values for your enum constants. Define the first constant with iota and let subsequent constants in the same block increment automatically.

const (
	StatusUnknown Status = iota
	StatusActive
	StatusInactive
)

This creates StatusUnknown as 0, StatusActive as 1, and StatusInactive as 2.