Go Goto Statement
# Go Language goto Statement
[Go Loop Statements](#)
The `goto` statement in Go can transfer control unconditionally to a specified line within a procedure.
The `goto` statement is typically used in conjunction with conditional statements. It can be used to implement conditional transfers, construct loops, and break out of loop bodies.
However, in structured programming, the use of the `goto` statement is generally discouraged to avoid causing confusion in the program flow, which can make understanding and debugging the program difficult.
### Syntax
The syntax for `goto` is as follows:
goto label;... label: statement;
The flowchart for the `goto` statement is as follows:
!(#)
### Example
Skip the current iteration and return to the beginning of the loop at the `LOOP` statement when the variable `a` equals 15:
## Example
package main
import"fmt"
func main(){
/* Define local variables */
var a int=10
/* Loop */
LOOP:for a <20{
if a ==15{
/* Skip iteration */
a = a +1
goto LOOP
}
fmt.Printf("avalue is : %dn", a)
a++
}
}
The execution result of the above example is:
avalue is : 10 avalue is : 11 avalue is : 12 avalue is : 13 avalue is : 14 avalue is : 16 avalue is : 17 avalue is : 18 avalue is : 19
[Go Loop Statements](#)
YouTip