Loop Control Statements in Go Language Last Updated : 19 Nov, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report 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: Break Goto Continue Break Statement 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. Flow Chart: Example: C // Go program to illustrate // the use of break statement package main import "fmt" // Main function func main() { for i:=0; i<5; i++{ fmt.Println(i) // For loop breaks when the value of i = 3 if i == 3{ break; } } } Output: 0 1 2 3 Goto Statement 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. Flow Chart: Example: C // Go program to illustrate // the use of goto statement package main import "fmt" func main() { var x int = 0 // for loop work as a while loop Lable1: for x < 8 { if x == 5 { // using goto statement x = x + 1; goto Lable1 } fmt.Printf("value is: %d\n", x); x++; } } Output: value is: 0 value is: 1 value is: 2 value is: 3 value is: 4 value is: 6 value is: 7 Continue Statement 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. Flow Chart: Example: C // Go program to illustrate // the use of continue statement package main import "fmt" func main() { var x int = 0 // for loop work as a while loop for x < 8 { if x == 5 { // skip two iterations x = x + 2; continue; } fmt.Printf("value is: %d\n", x); x++; } } Output: value is: 0 value is: 1 value is: 2 value is: 3 value is: 4 value is: 7 Comment More infoAdvertise with us A ankita_saini Follow Improve Article Tags : Go Language Go-Control-Flow Golang Similar Reads Go Programming Language (Introduction) Go is a procedural programming language. It was developed in 2007 by Robert Griesemer, Rob Pike, and Ken Thompson at Google but launched in 2009 as an open-source programming language. Programs are assembled by using packages, for efficient management of dependencies. This language also supports env 11 min read How to Install Go on Windows? Prerequisite: Introduction to Go Programming Language Before, we start with the process of Installing Golang on our System. We must have first-hand knowledge of What the Go Language is and what it actually does? Go is an open-source and statically typed programming language developed in 2007 by Robe 3 min read How to Install Golang on MacOS? Before, we start with the process of Installing Golang on our System. We must have first-hand knowledge of What the Go Language is and what it actually does? Go is an open-source and statically typed programming language developed in 2007 by Robert Griesemer, Rob Pike, and Ken Thompson at Google but 4 min read Hello World in Golang Hello, World! is the first basic program in any programming language. Letâs write the first program in the Go Language using the following steps:First of all open Go compiler. In Go language, the program is saved with .go extension and it is a UTF-8 text file.Now, first add the package main in your 3 min read Identifiers in Go Language In programming languages, identifiers are used for identification purposes. In other words, identifiers are the user-defined names of the program components. In the Go language, an identifier can be a variable name, function name, constant, statement label, package name, or type. Example: package ma 3 min read Go Keywords Keywords or Reserved words are the words in a language that are used for some internal process or represent some predefined actions. These words are therefore not allowed to use as an identifier. Doing this will result in a compile-time error. Example: C // Go program to illustrate the // use of key 2 min read Data Types in Go Data types specify the type of data that a valid Go variable can hold. In Go language, the type is divided into four categories which are as follows: Basic type: Numbers, strings, and booleans come under this category.Aggregate type: Array and structs come under this category.Reference type: Pointer 7 min read Go Variables A typical program uses various values that may change during its execution. For Example, a program that performs some operations on the values entered by the user. The values entered by one user may differ from those entered by another user. Hence this makes it necessary to use variables as another 9 min read Constants- Go Language As the name CONSTANTS suggests, it means fixed. In programming languages also it is same i.e., once the value of constant is defined, it cannot be modified further. There can be any basic data type of constants like an integer constant, a floating constant, a character constant, or a string literal. 6 min read Go Operators Operators are the foundation of any programming language. Thus the functionality of the Go language is incomplete without the use of operators. Operators allow us to perform different kinds of operations on operands. In the Go language, operators Can be categorized based on their different functiona 9 min read Like