Keyword
Go break keyword
Stops the innermost enclosing for, switch or select. A label can target an enclosing statement of one of these kinds in the same function. It does not return from the function. Example prints 0 and 1 on separate lines.
Formal Syntax & Structure
go syntaxgo
break [Label]Working Example
Example Snippetgo
package main
import "fmt"
func main() { for i := 0; i < 4; i++ { if i == 2 { break } fmt.Println(i) }}