Iota constants give small state codes clear names without storing magic numbers in the code.

Iota Status

iota_status.go
package main

import "fmt"

const (
	StatusDraft = iota
	StatusReview
	StatusPublished
)

func main() {
	var status = 
	label := "unknown"
	if status == StatusDraft {
		label = "draft"
	} else if status == StatusReview {
		label = "review"
	} else if status == StatusPublished {
		label = "published"
	}
	ready := status == StatusPublished

	fmt.Println("status=", status)
	fmt.Println("label=", label)
	fmt.Println("ready=", ready)
}
package main

import "fmt"

const (
	StatusDraft = iota
	StatusReview
	StatusPublished
)

func main() {
	var status = 
	label := "unknown"
	if status == StatusDraft {
		label = "draft"
	} else if status == StatusReview {
		label = "review"
	} else if status == StatusPublished {
		label = "published"
	}
	ready := status == StatusPublished

	fmt.Println("status=", status)
	fmt.Println("label=", label)
	fmt.Println("ready=", ready)
}
package main

import "fmt"

const (
	StatusDraft = iota
	StatusReview
	StatusPublished
)

func main() {
	var status = 
	label := "unknown"
	if status == StatusDraft {
		label = "draft"
	} else if status == StatusReview {
		label = "review"
	} else if status == StatusPublished {
		label = "published"
	}
	ready := status == StatusPublished

	fmt.Println("status=", status)
	fmt.Println("label=", label)
	fmt.Println("ready=", ready)
}
iota constants Keep the integer representation compact while using named constants at each decision point.