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 anti-pattern is tempting because non-blocking code feels safer, but it often turns coordination into dropped work or CPU spin.

Why

Related pages

Sources