
Concurrency
Iterators Instead of Channels in Go 1.23 and Later
Compare range-over-func iterators and channel generators in Go 1.23 and later: cost per item, early break, cancellation, iter.Pull and when channels win.
7 min read
Tag
3 articles

Compare range-over-func iterators and channel generators in Go 1.23 and later: cost per item, early break, cancellation, iter.Pull and when channels win.

Why time.After in a loop used to leak memory, what Go 1.23 changed for timers and tickers, how go.mod gates it, and the Reset pattern that remains.

Go 1.22 lets you range over an integer and Go 1.23 over an iterator function. See how yield works, the iter package helpers, early break and the go.mod rule.