Iteration over a map has undefined order. In fact, Go compiler goes to the trouble of randomizing the order so that programmers don't rely on accidental order.
There are 3 variants of iterating over a map with range
.
Get both key and value
https://codeeval.dev/gist/80c5989b8d98520e4a1a5cc667ca429a
Get only key
https://codeeval.dev/gist/bcc2905b2a30573dfc77f13bfe5acc24
Get only value