4 ms·
Not in 1.20 yet but x/exp/maps was just accepted for inclusion in the standard library so presumably it will come in a future version. The library contains gen
by donio 4y ago
Not in 1.20 yet but x/exp/maps was just accepted for inclusion in the standard library so presumably it will come in a future version.
The library contains generics based helper functions for working with maps.
https://github.com/golang/go/issues/57436#issuecomment-1412566002 https://github.com/golang/go/issues/57436#issuecomment-14125...
https://pkg.go.dev/golang.org/x/exp/maps https://pkg.go.dev/golang.org/x/exp/maps
https://cs.opensource.google/go/x/exp/+/master:maps/maps.go https://cs.opensource.google/go/x/exp/+/master:maps/maps.go
- eatonphil 4y agoVery useful. I am always writing a little Clone() function for maps.
- latchkey 4y agoGlad to see this make it into the core. I've been using this library for ages now... https://github.com/cornelk/hashmap https://github.com/cornelk/hashmap Always entertains me to see developers write all the lock/unlock code when they could just use that.
- kyrra 4y agoWe likely need full coverage of the "tricks" documented on https://github.com/golang/go/wiki/SliceTricks https://github.com/golang/go/wiki/SliceTricks into a generics package as well. Yes, https://pkg.go.dev/golang.org/x/exp/slices https://pkg.go.dev/golang.org/x/exp/slices gives some of that, but likely the rest should be added as well.
- impulser_ 4y agoHopefully they accept the slice version as well. Both of them contain very helpful functions that would be nice to have in the std library instead of rewriting them every where.
- tptacek 4y agoYou don't rewrite them; you just import exp/slices. The only thing bringing them into std really changes in practice is the import path.