The for Loop: All Patterns
Classic, while-style, infinite, and range loops
Go Has Only One Loop
Go has only the for loop — no while, no do-while. The for keyword covers all iteration patterns through different forms.
Classic C-Style for Loop
The traditional three-clause loop:
for i := 0; i < 5; i++ {
fmt.Println(i)
}All lessons in this course
- if Statements and Init Expressions
- The for Loop: All Patterns
- switch Statements in Go
- break, continue and Labels