Go has only one looping construct: the for loop. The for loop has 3 components separated by semicolons:
The Init statement, which is executed before the loop begins. It’s often a variable declaration only visible within the scope of the for loop.
The condition expression, which is evaluated as a Boolean before each iteration to determine if the loop should continue.
The post statement, which is executed at the end of each iteration.
package main
import "fmt"
func main() {
sum := 0
for i := 0; i < 10; i++ {
sum += i
}
fmt.Println(sum)
}