I’ve read this summary of iterators in Go repeatedly over the years. This morning I read Generators in Go and realized I’d failed to internalize what might be the most natural-feeling option: channel
+ range
.
Early break
remains a garbage collection issue, though.