is there a ordered dictionary/ map in golang?. what options do i have? in python i have ordered dicts. what options do i have?
// this is not ordered
src map[string]interface{}
// this is not ordered
src map[string]string{}
i got this
- https://pkg.go.dev/github.com/wk8/go-ordered-map,
- https://github.com/elliotchance/orderedmap/.
just want to check if this is inbuilt available?
1
There is no build in sorted map, but an open proposal.
The best you can do in Go 1.23 is
import (
"maps"
"slices"
)
...
for _, k := range slices.Sorted(maps.Keys(m)) {
...
}
Otherwise, there are examples and a discussion of libraries in the open issue.