> ## 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 Condition For Loop

In Go, a condition-only `for` loop is a control flow statement that repeatedly executes a block of code as long as a specified boolean expression evaluates to `true`. It serves as Go's idiomatic equivalent to the `while` loop found in other C-family languages, as Go intentionally omits the `while` keyword from its syntax.

```go theme={"dark"}
for condition {
    // loop body
}
```

## Technical Characteristics

* **Strict Boolean Evaluation:** The `condition` must be a strictly typed boolean expression. Go does not support "truthiness" evaluation; you cannot use integers (e.g., `1` or `0`), strings, or pointers directly as the loop condition.
* **Omission of Semicolons:** When using the condition-only form, the initialization and post-statement components of a standard three-part `for` loop (`for init; condition; post`) are entirely omitted, along with their separating semicolons.
* **State Mutation:** Because there is no built-in post-statement to increment or decrement a counter, the state evaluated by the `condition` must be mutated within the loop body to prevent an infinite loop.
* **Lexical Scoping:** Variables evaluated in the condition are typically declared in the outer lexical scope prior to the loop. Variables declared within the loop body are scoped strictly to the current iteration.

## Execution Flow

1. The boolean `condition` is evaluated.
2. If the condition evaluates to `true`, the loop body executes sequentially.
3. Upon reaching the end of the loop body, control flow returns to step 1.
4. If the condition evaluates to `false`, the loop terminates, and control flow transfers to the statement immediately following the loop block.

## Syntax Example

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

import "fmt"

func main() {
    n := 1 // State initialized in the outer scope

    // Condition-only for loop
    for n < 5 {
        fmt.Println(n)
        n *= 2 // State mutated within the loop body
    }
}
```

## Control Flow Modifiers

The execution of a condition-only `for` loop can be altered internally using standard Go jump statements:

* `break`: Immediately terminates the loop entirely, bypassing the condition evaluation.
* `continue`: Halts the current iteration, skips any remaining statements in the loop body, and immediately re-evaluates the `condition` for the next iteration.

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