The Break statement can exit the for loop, and the statement after the Break will not be executed.
The following is a complete code example.
package main
import "fmt"
func main() {
i := 0
for {
if i > 5 {
break
}
fmt.Println(i)
i++
}
}
Below is the program output:
0
1
2
3
4
5