How to Use break and continue in Go Loops

Use break to exit a loop immediately and continue to skip the current iteration and proceed to the next one.

Use break to exit a loop immediately and continue to skip the rest of the current iteration and jump to the next one.

for i := 0; i < 10; i++ {
    if i == 3 {
        continue // Skips printing 3
    }
    if i == 7 {
        break // Exits the loop entirely
    }
    fmt.Println(i)
}
// Output: 0 1 2 4 5 6