This question as already been asked three years ago, but I would like to know whether the situation has changed.
Many proof of concepts and toy projects exist, but I'm wondering whether something more solid is maintained.
So far I found :
- Go By Example : collection functions (very simple)
- Go-Underscore (not maintained)
- Golang-Underscore (not maintained)
- Godash (not maintained, was destroyed on this sub)
- Filter (not maintained)
评论:
clvrname:
yellowiscool:
mixedCase_:Thanks. It seems a bit overkill for my usage, but it's definitely interesting to see alternatives to Apache Spark and similar in Go.
yellowiscool:The situation is the same and will not change at the very least until Go 2 if generics are added or if they're (map/filter/reduce) special-cased into the language like the range keyword (very unlikely).
tv64738:Could they add a standard library with more advanced and high level data containers? Being thread safe and supporting map/reduce/filter for example. C# provides that and it's very convenient.
mixedCase_:"Thread safe" containers are typically the wrong thing. You want atomic semantic actions, for whatever the application logic is.
For example: if key K is not in this set, allocate a new value with key K and add it. Trying to construct that from just atomic get/set is the wrong way around.
thesnowmancometh:No, as Go libraries are written in Go and Go doesn't have generics, while C# does.
yellowiscool:By the creator of Go himself: https://github.com/robpike/filter As he indicates, you shouldn't use it for professional code. Just use a for loop because not everyone has to understand functional operations.
faiface:Thanks. I saw it, but I want to write professional code and I think functional operations are sometimes more readable than for loops.
thesnowmancometh:Actually, that package is probably as production-ready as this kind of stuff can possibly get in Go.
The reason that he does not recommend actually using it, is that this just doesn't fit in Go. One of the reasons being generics. Also, it can unexpectedly slow down your code, since Go doesn't do lazy evaluation.
If you really want to use it, use the Rob Pike's package, it won't get much better.
yellowiscool:How do you plan to do that with type safety?
itsmontoya:Yeah, go is missing generics.
yellowiscool:I wrote a simple linked list data store which offers map, filter, and reduce. Feel free to borrow any of the concepts used.
itsmontoya:Thanks, I will take a look.
Redundancy_:For sure! If you have any questions feel free to ask.
Slightly different: https://github.com/Redundancy/fileMapReduce
