Go Iterators: A Tale of Purity and Impurity
2025-05-31
Go 1.23 standardized iterators, powerful functions that can be closures. However, the official documentation's classification of iterators is ambiguous. The author proposes a clearer distinction between 'pure' and 'impure' iterators: 'pure' iterators restart each time, while 'impure' iterators may retain state. The article explores various iterator types and the trade-offs between performance and consistency, concluding that Go's iterator landscape is still evolving, with conventions and terminology needing further refinement.
Development