Canonical guidance

Use when

Avoid

Preferred pattern

for {
	select {
	case <-ctx.Done():
		return ctx.Err()
	case item, ok := <-in:
		if !ok {
			return nil
		}
		handle(item)
	}
}

Anti-pattern

Explanation: This is tempting because it feels responsive, but it burns CPU and still fails to model lifecycle cleanly.

Why

Related pages

Sources