> ## 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 Break Statement

The `break` statement is a control flow construct used to immediately terminate the execution of the innermost enclosing `for`, `switch`, or `select` statement. Upon execution, control is transferred to the statement immediately following the terminated block.

## Syntax

Go supports two forms of the `break` statement: unlabeled and labeled.

```go theme={"dark"}
// Unlabeled break
break

// Labeled break
break LabelName
```

## Unlabeled Break Mechanics

When executed without a label, `break` operates strictly on the innermost control structure containing it.

* **In `for` statements:** It halts the loop entirely. Any remaining iterations, including the post-statement (e.g., `i++`) and the condition evaluation, are bypassed.
* **In `switch` and `select` statements:** It terminates the execution of the current `case` block and exits the `switch` or `select` structure. Because Go implicitly breaks at the end of each `case`, an explicit `break` is mechanically used to short-circuit the execution of a `case` block before reaching its lexical end.

**Execution Flow Visualization:**

```go theme={"dark"}
for i := 0; i < 5; i++ {
    if i == 2 {
        break // Execution jumps directly to Statement A
    }
    // Skipped when i == 2
}
// Statement A: Control resumes here
```

## Labeled Break Mechanics

A labeled `break` is used to terminate an outer enclosing `for`, `switch`, or `select` statement from within a nested structure.

The target label must be declared immediately preceding the control structure it identifies. According to the Go specification, the scope of a label is the entire body of the function in which it is declared (excluding nested functions). Consequently, a label name must be unique across the entire function body. However, labels reside in a separate namespace, meaning they do not conflict with standard identifiers like variables or types in the lexical block scope.

Label resolution and control flow jumps are handled by the Go compiler at compile-time, translating directly into jump instructions rather than being dynamically evaluated by the Go runtime. When `break LabelName` is executed, it terminates the specific control structure associated with `LabelName`, transferring control to the statement immediately following that labeled block.

**Execution Flow Visualization:**

```go theme={"dark"}
OuterControl:
    for i := 0; i < 3; i++ {
        switch i {
        case 1:
            for j := 0; j < 3; j++ {
                break OuterControl // Execution jumps directly to Statement B
            }
        }
    }
// Statement B: Control resumes here
```

## Lexical Constraints

1. **Valid Targets:** A `break` statement (labeled or unlabeled) is syntactically invalid if it is not lexically enclosed by a `for`, `switch`, or `select` statement within the same function.
2. **Label Association:** A labeled `break` must refer to a label that directly precedes a `for`, `switch`, or `select` statement. It cannot target arbitrary block labels or labels attached to unsupported statement types (such as `if` statements).

<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>
