iota is a predeclared constant in Go that automatically increments by 1 for each line in a const block, starting at 0. It is primarily used to create compact, readable enumerations without manually typing sequential numbers.
const (
FormatUnknown Format = iota
FormatV7
FormatUSTAR
FormatPAX
FormatGNU
)
This pattern assigns 0 to FormatUnknown, 1 to FormatV7, 2 to FormatUSTAR, and so on, ensuring values remain unique and sequential.