|
|
package main
|
|
import "fmt"
|
|
func main() {
|
|
The most basic type, with a single condition. |
i := 1
for i <= 3 {
fmt.Println(i)
i = i + 1
}
|
A classic initial/condition/after |
for j := 7; j <= 9; j++ {
fmt.Println(j)
}
|
|
for {
fmt.Println("loop")
break
}
}
|
$ go run for.go
1
2
3
7
8
9
loop
|
|
We’ll see some other |
Next example: If/Else.