Overview In this blog I am going to talk about the topic below. Loop break continue infinity collection Panic Switches Loop You can use loop as below. here i variable is declared inside the loop so the value will be valid in side the loop. Example package main import ( "fmt" ) func main() { for i:=0;i<5;i++{ fmt.Println(i) } } output : 0 1 2 3 4 5 Break in Loop what Break statement dose is it will break out from the loop. package main import ( "fmt" ) func main() { for i:=0;i<5;i++{ fmt.Println(i) if i==2 { break } } } output : 0 1 2 in the example you can see when loop comes to the point when i == 2 then it break out from the loop and end the program. this why it out put the value of i until it is