// labelled breaks in Go // labels must be associated (immediately precede) with for, switch or select // select is only used in multi-threaded programs // break use in switch is obscure side case package main import "fmt" // each label is a part of the scope of its associated switch/for // so outouter label disappear after its for loop. func main() { k:=0 outouter: for { if k>8 { fmt.Println("k break") break outouter } fmt.Printf("KK: %d\n", k) k++ } outer: for i:=0; i<7; i++ { j:=0 inner: for { fmt.Printf("IJ: %d %d\n", i, j) if i*j>12 { fmt.Println("IJ break") break outer } if j>4 { fmt.Println("J break") break inner } j++ } } switcher(2,1) switcher(2,4) } func switcher(ii,jj int) { labell: switch (ii) { case 1: fmt.Println("ONE") case 2: if (jj>3) { break labell } fmt.Println("TWO") case 3: fmt.Println("three") } }