for (three forms)
Go's only loop.
Syntax
for i := 0; i < n; i++ { }Description
for handles all kinds of loops: classic (3 parts), conditional (like while: for condition {}), and infinite (for {}).
Example
Loading editor…
Expected output
1 2 3
When to use?
Known repetition.