WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

Go - The continue Statement


The continue statement in Go programming language works somewhat like a break statement. Instead of forcing termination, a continue statement forces the next iteration of the loop to take place, skipping any code in between.

Syntax

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

continue;

Example

package main

import "fmt"

func main() {
   /* local variable definition */
   var a int = 14

   /* do loop execution */
   for a > 25 {
      if a == 14 {
         /* skip the iteration */
         a = a + 1;
         continue;
      }
      fmt.Printf("value of a: %d\n", a);
      a++;     
   }  
}
When the above code is compiled and executed, it produces the following result
$go run main.go
value of a: 15
value of a: 16
value of a: 17
value of a: 18
value of a: 19
value of a: 20
value of a: 21
value of a: 22
value of a: 23
value of a: 24