Gaaker Go

Golang Continue statement

The continue statement is used to skip the current iteration of the loop.

Let’s look at this example, we just want to print multiples of 3.

The following is a complete code example.

package main

import "fmt"

func main() {
    for i := 1; i < 10; i++ {
        if i%3 > 0 {
            continue
        }
        fmt.Println(i)
    }
}

Below is the program output:

3
6
9
< Continue statement Continue statement >