Code-Memo

While-style loops

Go does not have a separate while keyword. Any “while” loop is written with for and a condition.

Basic pattern
n := 1
for n < 100 {
	n *= 2
}
Read until sentinel
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
	line := scanner.Text()
	if line == "quit" {
		break
	}
	// handle line
}
Retry with backoff (sketch)
for attempt := 1; attempt <= 5; attempt++ {
	if err := try(); err == nil {
		break
	}
	time.Sleep(time.Duration(attempt) * 100 * time.Millisecond)
}

Use continue to skip to the next iteration and break to exit the innermost loop (or use a label for an outer loop).