-
It is a consequence of (a) Go's implicit relationship between a concrete type and the interfaces it implements and (b) Go's "heterogenous" translation of generics (like C++, unlike Java). Together, this means you can't know which methods you need a priori. All proposed solutions to date essentially compromise on (a) by limiting the generic "implements" relation to things known at build time, or on (b) by making generic methods "homegenous" (aka boxed) and thus slow.
See https://github.com/golang/go/issues/49085#issuecomment-23163... for an example of the latter.
-
CodeRabbit
CodeRabbit: AI Code Reviews for Developers. Revolutionize your code reviews with AI. CodeRabbit offers PR summaries, code walkthroughs, 1-click suggestions, and AST-based analysis. Boost productivity and code quality across all major languages with each PR.
-
Might be interesting to make a library that competes with https://github.com/samber/lo?
-
Back when the Go team announced generics, I had a go (pun intended) at it: https://github.com/gtramontina/go-extlib -- might resurrect it one day. `lo` is pretty comprehensive though.
-
Here's one: https://github.com/szmcdull/glinq It doesn't do function chaining though.
-
Shameless plug. I had experimented with Go iterators a while ago and did a https://github.com/gomoni/it
It was updated to 1.23, so it is as idiomatic as I can get. And yes it has a map method between two types. Just a single simple trick used.
-
The argument types for lambdas need to be provided to work around C# lacking full Hindler-Milner type inference, but this iterator expression is fully statically dispatched and monomorphized save for the lambdas themselves. Luckily, JIT can profile the exact method types passed to Funcs and perform further guarded devirtualization, putting this code painfully close to the way Rust's iterators are compiled.
[0]: https://github.com/neon-sunset/project-anvil/blob/master/Sou...
-
We just released a go pkg that uses the new iter pkg. We were so excited by the interface in large part because of how simple iterators are to use.
https://github.com/picosh/pubsub/blob/main/pubsub.go#L18
We have seen in other languages like JS and python the power of iterators and we are happy to see it in Go
-
SaaSHub
SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives
-
ah, that's what it's called! I did this in my compile-to-Go language, but I didn't know the name for it: https://github.com/lukechampine/ply?tab=readme-ov-file#suppo...
-
Funny enough, the iterator version is much faster in rust because the compiler can more easily optimize iterator chains than custom for loops:
https://play.rust-lang.org/?version=stable&mode=release&edit...
(I'd recommend running it on your own machine as the rust playground limits memory and will likely kill this program)
Output from my machine:
$ cargo run --release
-
Related posts
-
Go is not an easy language (2021)
-
Functional Programming Library for Golang by IBM
-
A lightweight Golang generics library that provides Map, Reduce and more
-
A lightweight Golang generics library that provides Map, Reduce and more
-
A lightweight Golang generics library that provides Map, Reduce and more