Infinite Loops

If you omit all three sections of a for loop (initialization, condition, and post-iteration), you create an infinite loop.

Syntax

for {
    // do something forever
}

Breaking Out

Infinite loops are usually used in conjunction with a break statement or a return to exit when a specific condition is met internally.

for {
    if condition {
        break
    }
    // ...
}

This pattern is common in server listening loops or background workers that need to poll resources continuously.