Golang (Go) Tutorial - Loops
๐ Loops - Repeat Tasks
Real Life:
๐ Exercise: 10 push-ups repeat
๐ Homework: 20 questions solve
๐ฎ Game: Jab tak lives hai
Go Has ONLY For Loop!
3 Styles
// Style 1: Traditional
for i := 0; i < 5; i++ {
fmt.Println(i)
}
// Style 2: While-like
i := 0
for i < 5 {
fmt.Println(i)
i++
}
// Style 3: Infinite
for {
// use break
}
Example
for i := 1; i <= 10; i++ {
fmt.Println(i)
}