Iota in Go

Iota is used to simplify the declaration of constants with incrementing values. It starts at 0 and automatically increments by 1 with each line in a constant block. It’s is used to create basic enums in Go by assigning sequential integer values to a set of related constants.

Example:

package flavors

import _ "embed"

type Enum int

const (
    GitHub Enum = iota
    Pico
)

//go:embed css/github.css
var githubCSS string

//go:embed css/pico.css
var picoCSS string

func (enum Enum) GetCss() string {
    switch enum {
    case GitHub:
        return githubCSS
    case Pico:
        return picoCSS
    default:
        panic("Missing Enum")
    }
}