Get the latest tech news
Fun with Go Iterators
Go 1.23 added Iterators, so lets build a js like streaming api
Because i have a big distaste for writing chained “functional” operations like this, looking at you python (don’t come at me haskell bros) - I wanted to use the new iterators and the iter package and wrap it with a structure to allow the nice and clean chaining JavaScript provides. Lets first take a look at the signature, we are returning a pointer to the struct, so the callee can invoke all methods without having to use a temporary variable for each. The slices and the iter package both play very good together with the generic system introduced in go 1.18 .
Or read this on Hacker News