iter: Generic, lazy iterators for Go 1.18

This page summarizes the projects mentioned and recommended in the original post on reddit.com/r/golang

Our great sponsors
  • InfluxDB - Access the most powerful time series database as a service
  • SonarQube - Static code analysis for 29 languages.
  • SaaSHub - Software Alternatives and Reviews
  • iter

    Package iter provides generic, lazy iterators, functions for producing them from primitive types, as well as functions and methods for transforming and consuming them. (by mtoohey31)

    The reason why I decided on the inner/outer architecture was because interface objects can't be used as recievers to methods (as far as I understand). As a result, my initial implementation, which didn't have this structure, was limited to functions instead of methods, which made code where iterator methods were chained extremely unreadable, since it was difficult to tell which order they were being applied in. It's a tradeoff, but I think the readability might be worth it. Do you have any ideas for alternative workarounds?

  • go

    The Go programming language

    Also, can anyone explain the error "instantiation cycle" to me? I have two methods commented for which this was occuring: Position in iter.go, and ZipEndo in zip.go, and I'm not sure what this error means, or why it occurs, since the corresponding function implementation (Zip) of ZipEndo has no such problem. I don't believe it's an implementation bug in the tuple package, since I was originally using my own simple 2-value tuple struct and the exact same error ocurred. The only thing I can find about it online is this post, but I'm not sure how the answer there applies to either of my cases...

  • InfluxDB

    Access the most powerful time series database as a service. Ingest, store, & analyze all types of time series data in a fully-managed, purpose-built database. Keep data forever with low-cost storage and superior data compression.

  • gtools

    Generic tools for go 1.18+

    Looks good Do you benchmark it vs for loop? Recently I am wrote pretty similar lib but using functions for all(filter, ForEach etc): gtools Maybe you will find something for yours lib

  • go-iterator

    Go 1.18 generics iterator experiment

    Regarding call chaining, it is still possible to chain things with operations that return different types, but they have to be done with functions instead of methods, so the result is still the same, just it's a little less readable. There is a generic iterator implementation by polyfloyd that doesn't support method chaining, but imo being able to chain iterators is one of their biggest strengths, since implementing lazy evaluation manually for a single operation isn't that difficult, its when you need to perform multiple kinds of manipulations that it gets messy.

  • go-generic

    A collection of experiments using Go Generics coming out in Go 1.18

    I did some experimenting of my own and came up with this design: https://github.com/qualidafial/go-generic/tree/master/iter

  • SonarQube

    Static code analysis for 29 languages.. Your projects are multi-language. So is SonarQube analysis. Find Bugs, Vulnerabilities, Security Hotspots, and Code Smells so you can release quality code every time. Get started analyzing your projects today for free.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts