How do i prevent default sorting in map and maintain order of insertion?

How do i prevent default sorting in map and maintain order of insertion?

You need a specialised map type. Gos builtin maps are unordered.

I can not say anything about the quality of this, but orderedmap package - github.com/wk8/go-ordered-map/v2 - pkg.go.dev claims to do what you want.

1 Like