Predeclared constant

Go iota constant

Untyped integer constant representing the zero-based index of the current ConstSpec in a const declaration. It resets for each const declaration; repeated expressions can produce enumerations or bit flags. Example output: '1 2 4'.

Formal Syntax & Structure

go syntaxgo
iota

Working Example

Example Snippetgo
package main
import (  "fmt")
func main() {  const (    read = 1 << iota    write    execute  )  fmt.Println(read, write, execute)}
Go Reference