Ian Lance Taylor's GopherCon 2024 talk covers the new Go 1.23 feature: range over function types. The talk explains the motivation — the lack of a standard iteration protocol for user-defined container types — and introduces push iterators (functions that call a yield function with each value, usable directly in for-range loops) and pull iterators (functions that return one value per call, useful for parallel iteration). The new `iter` package defines `Seq` and `Seq2` types as standard iterator signatures. New helper functions in `slices` and `maps` packages support iterators, and `iter.Pull` converts push iterators to pull iterators. Examples include iterating over a generic Set, a binary tree, and byte-slice lines without extra allocations.

23m watch time
18 Impressions