Loop control statements in the Go language are used to change the execution of the program. When the execution of the given loop left its scope, then the objects that are created within the scope are also demolished. The Go language supports 3 types of loop control statements:
The break statement is used to terminate the loop or statement in which it presents. After that, the control will pass to the statements that present after the break statement, if available. If the break statement present in the nested loop, then it terminates only those loops which contains break statement.
0 1 2 3
This statement is used to transfer control to the labeled statement in the program. The label is the valid identifier and placed just before the statement from where the control is transferred. Generally, goto statement is not used by the programmers because it is difficult to trace the control flow of the program.
value is: 0 value is: 1 value is: 2 value is: 3 value is: 4 value is: 6 value is: 7
This statement is used to skip over the execution part of the loop on a certain condition. After that, it transfers the control to the beginning of the loop. Basically, it skips its following statements and continues with the next iteration of the loop.
value is: 0 value is: 1 value is: 2 value is: 3 value is: 4 value is: 7
- Combining Conditional Statements in Golang
- How to iterate over an Array using for loop in Golang?
- How to use for and foreach loop in Golang?
- Switch Case with Break in For Loop in Golang
- Select Statement in Go Language
- Constants- Go Language
- Loops in Go Language
- Identifiers in Go Language
- Function Returning Multiple Values in Go Language
- Anonymous function in Go Language
- Difference Between Go and Python Programming Language
- Golang Tutorial - Learn Go Programming Language
- How to get int63 type random number in Go language?
- Go Programming Language (Introduction)
- Functions in Go Language
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : nidhi_biet