How to Write For Loops in Go (The Only Loop)

Go uses a single `for` loop construct that supports standard, while, and infinite loop patterns by adjusting its three components.

Go has only one loop construct: the for loop, which handles standard iteration, while-loops, and infinite loops.

// Standard loop with initialization, condition, and post-statement
for i := 0; i < 10; i++ {
    fmt.Println(i)
}

// While-loop style (omit init and post)
for i < 10 {
    fmt.Println(i)
    i++
}

// Infinite loop (omit condition)
for {
    fmt.Println("running forever")
}