Go - The goto Statement

A goto declaration in Go programming language gives an unconditional bounce from the goto to a categorized announcement in the equal characteristic.


The syntax for a goto statement in Go is as follows −

goto label;
Label: declaration;


package principal

import "fmt"

func foremost() 
   /* neighborhood variable definition */
   var a int = 12

   /* do loop execution */
   LOOP: for a < 25 
      if a ==17 
         /* pass the iteration */
         a = a + 1
         goto LOOP
      fmt.Printf("value of a: %dn", a)

When the above code is compiled and accomplished, it produces the following end result
$cross run primary.Move
fee of a: 12
value of a: thirteen
cost of a: 14
price of a: 15
value of a: 16
price of a: 18
fee of a: 19
fee of a: 20
value of a: 21
cost of a: 22
value of a: 23
fee of a: 24