Skip to content

Instantly share code, notes, and snippets.

@R4wm
Last active September 17, 2017 18:27
Show Gist options
  • Save R4wm/dc992645cf2201d3ac47a901ded04fbc to your computer and use it in GitHub Desktop.
Save R4wm/dc992645cf2201d3ac47a901ded04fbc to your computer and use it in GitHub Desktop.
iota example
package main
import "fmt"
//using iota to declare value and inc
const (
A1 = iota //Start at 0
B1 = iota //Inc by 1
C1 = iota //Inc by 1
)
const (
A2 = iota //Start at 0
B2 //Inc by 1
C2 //Inc by 1
)
const (
A3 = iota + 3 //Start at 3
B3 //Inc by 1
C3 //Inc by 1
)
func main() {
println("print first example:")
fmt.Printf("A1: %d\nB1: %d\nC1: %d\n", A1, B1, C1)
println("print second example")
fmt.Printf("A2: %d\nB2: %d\nC2: %d\n", A2, B2, C2)
println("print third example (starting at 3)")
fmt.Printf("A3: %d\nB3: %d\nC3: %d\n", A3, B3, C3)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment