0Pricing
Go Academy · Lesson

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

  1. if Statements and Init Expressions
  2. The for Loop: All Patterns
  3. switch Statements in Go
  4. break, continue and Labels
← Back to Go Academy