Chains: My Attempt at an Itertools for Go
Top Matter: GitHub for the library, doc for the library.
It’s been six months since I’ve done this, but I’m finally writing about it!
Go recently added proper iterator support to the language, which is something of an improvement over the prior pattern of spinning up a goroutine and communicating via a channel in a range to get a stream of values.
One of the tools in my toolbox that I use in coding interviews and some light data processing work is Python’s itertools. The nice thing about this library is it gives you a good set of conceptual building blocks to use as a frame around a problem and a fairly clean way to use them. Once you’re familiar with, say, combinations and permutations you can take a harder problem and decompose it into those recognizable parts and then have a stdlib function that’s already bug free and readily available.