> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Go Continue Statement

The `continue` statement in Go is a control flow directive used exclusively within `for` loops to terminate the execution of the current iteration. When a `continue` statement is executed, it immediately halts execution of the remaining statements in the current loop body and advances control to the next iteration of the loop.

## Syntax

```go theme={"dark"}
continue
// or
continue LabelName
```

## Execution Mechanics

The exact behavior of the `continue` statement depends on the variant of the `for` loop in which it is invoked:

1. **Standard `for` loop (`for init; condition; post`)**: Control flow jumps directly to the `post` statement (e.g., `i++`), executes it, and then evaluates the `condition` to determine if the loop should proceed.
2. **Condition-only `for` loop (`for condition`)**: Control flow jumps directly to the evaluation of the loop `condition`.
3. **`for range` loop**: Control flow jumps to the assignment of the next sequence values (index/key and value) and proceeds with the next iteration.
4. **Infinite loop (`for {}`)**: Control flow jumps directly back to the beginning of the loop body.

```go theme={"dark"}
package main

import "fmt"

func main() {
    for i := 0; i < 5; i++ {
        // Statement A
        condition := (i == 2)
        if condition {
            continue // Bypasses Statement B; jumps directly to i++
        }
        // Statement B (Skipped when condition is true)
        fmt.Println(i)
    }
}
```

## Labeled `continue`

Go supports labeled `continue` statements, which are used to manage control flow within nested loops. By default, an unlabeled `continue` applies only to the innermost enclosing `for` loop. By appending a label, you can explicitly instruct the program to continue the iteration of a specific outer loop.

A label is declared using an identifier followed by a colon (`:`) and must be positioned immediately preceding the target `for` loop.

```go theme={"dark"}
package main

import "fmt"

func main() {
OuterLoop:
    for i := 0; i < 3; i++ {
        for j := 0; j < 3; j++ {
            condition := (j == 1)
            if condition {
                // Halts the inner loop's current iteration.
                // Jumps directly to i++ of the OuterLoop.
                continue OuterLoop 
            }
            fmt.Printf("i=%d, j=%d\n", i, j)
        }
    }
}
```

## Lexical Constraints

* A `continue` statement must be lexically nested inside a `for` loop. Using it outside of a loop structure results in a compile-time error (`continue is not in a loop`).
* When using a labeled `continue`, the specified label must be defined in the same function and must directly precede a `for` loop that encloses the `continue` statement. It cannot be used to jump to arbitrary labels in the code.

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor Go Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
