Exit a loop in Golang

The break and continue keywords work just as they do in C, Java and Python.

A continue statement begins the next iteration of the innermost for loop at its post statement (n++):

for n := 0; n <= 5; n++ {
    if n%2 == 0 {
        continue
    }
    fmt.Println(n)
}
A break statement leaves the innermost for, switch or select statement:
number := 1
// loop that runs infinitely
for {
  // condition to terminate the loop
  if number > 5 {
    break;
  }

  fmt.Println(number);
  number++
}