Go has only one looping construct, the for loop.
The basic for loop has three components separated by semicolons:
* the init statement: executed before the first iteration
* the condition expression: evaluated before every iteration
* the post statement: executed at the end of every iteration
```
package main
import "fmt"
func main() {
for j := 1; j < 5; j++ {
fmt.Println(j)
}
}
```
Note: Unlike other languages like C, Java, or JavaScript there are no parentheses surrounding the three components of the for statement and the braces { } are always required.
The init and post statements are optional. C's while is spelled for in Go.
```
sum := 1
for ; sum < 1000; {
sum += sum
}
```
If you omit the loop condition it loops forever, so an infinite loop is compactly expressed.
```
for {
fmt.Println("loop")
break
}
```