Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
Tips & Traps¶
There are 2 implementations of ordered map in Golang orderedmap and go-ordered-map . orderedmap is more popular (based on GitHub statistics) and thus is preferred.
import "github.com/elliotchance/orderedmap/v2"error executing "/usr/local/go/bin/go build -buildmode=plugin" in directory "/home/dclong/go/src/gomacro.imports/gomacro_pid_7244/import_1": exit status 2var m OrderedMap[string, any]repl.go:1:17: expected ';', found '['m := orderedmap.NewOrderedMap[string, any]()
mrepl.go:1:37: expected ']', found ',' m.Set("foo", "bar")
m.Set("qux", 1.23)
m.Set("123", true)
m.Delete("qux")m := orderedmap.NewOrderedMap[string, any]()
m.Set("foo", "bar")
m.Set("qux", 1.23)
m.Set("123", true)
m.Delete("qux")References¶
🟢 encoding/json: no way to preserve the order of map keys encoding/json: no way to preserve the order of map keys