How to use 'golang iota' in Go

Every line of 'golang iota' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Go code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
122func show_iota() {
123 fmt.Println("show_iota()")
124 const (
125 x = iota // x == 0
126 y = iota // y == 1
127 z = iota // z == 2
128 w // Se não houver nenhuma expressão após o nome da constante,
129 // ela usa a última expressão, ou seja, neste caso w = iota implicitamente.
130 // Portanto w == 3, e tanto y quanto z podem omitir "= iota" também.
131 )
132
133 const v = iota // uma vez que iota encontra a palavra-chave `const`, ela é redefinida para `0`, então v = 0.
134
135 const (
136 e, f, g = iota, iota, iota // e=0,f=0,g=0 valores de iota são iguais quando estão na mesma linha.
137 )
138 fmt.Printf("x = %v, y = %v, z = %v, w = %v\n", x, y, z, w)
139 fmt.Printf("v = %v\n", v)
140 fmt.Printf("e = %v, f = %v, g = %v\n", e, f, g)
141}

Related snippets