Does break in Go break only switch/select or also the outer loop?
Hello everyone! I started learning Go recently and encountered unexpected behavior of the `break` statement. I have a `for` loop with a `switch` inside it. I expected that `break` inside the `case` would break the loop, but it didn't happen.
Here's a simplified example of my code:
```go
package main
import "fmt"
func main() {
for i := 0; i < 5; i++ {
switch i {
case 2:
fmt.Println("Found 2, exiting the loop!")
break // I thought this would break the for loop
default:
fmt.Printf("Iteration %d\n", i)
}
}
fmt.Println("Loop ended")
}
```
I expected that after printing "Found 2, exiting the loop!" the program would terminate the loop and print "Loop ended". However, in practice, the program continues iterations: 0, 1, "Found