An experimental collection (partly inspired by Haskell's prelude) of utility functions for working with Go iterators.
go get github.com/jub0bs/iterutil
jub0bs/iterutil requires Go 1.23 or above.
The documentation is available on pkg.go.dev.
All source code is covered by the MIT License.
You can, but at your own peril. As stated above, this library is experimental; more than anything else, it's an excuse for me to flex my functional-programming muscles and familiarize myself with Go 1.23's iterators. At this early stage, I reserve the right, upon new releases, to break the API: some functions may see their names and/or signatures change, and some functions may be removed altogether.
If you need a few functions from this library but do not want to depend on it, feel free to copy their sources in your project; a little copying is better than a little dependency.
Above all, use it with parsimony. The functional style displayed by this library is far from ideal in Go, for several reasons:
- code readability may suffer, in part because Go's idiosyncracies hinder a "fluent interface" style and because Go lacks a concise notation for anonymous functions;
- a more classic and imperative style is likely to prove much more performant;
- Go lacks the powerful laziness of Haskell.
Bear in mind that the existence of this library is no license to adopt a functional style all over your codebase!