Other languages use several loop keywords. Go keeps one keyword, for, and changes its shape for counting, condition-based, and endless loops.
Go code
for {
fmt.Println("Once")
break
}Line-by-line explanation
- For with no condition begins an endless loop.
- Println displays Once.
- Break immediately ends the loop.
Expected output
OnceThis is the expected result.