This is a creation in Article, where the information may have evolved or changed.
According to my understanding of the map, the data in the map should be ordered binary tree storage sequence, the normal traversal should also be an orderly traversal and output, but actually tried, but found that not so, on-line check the next, found from Go1 start, the beginning of the traversal of the node is random, of course, to what extent is not clear.
Package Mainimport ("FMT") func main () {x: = Do (map[int]int) for I: = 0; i <; i++ {X[i] = I}for k, V: = range x {FMT . Println (k, V)}}
After the build is executed multiple times, the results of each output are different. Of course, with FMT. PRINTLN ("Map:", x) output is also an unordered result
Referring to http://xhrwang.me/2014/12/25/golang-fundamentals-4-map-range.html, I understand that to create an index for a reference type (Slice,map,channel) at range The index of map is not specified, so it is unordered.
So if you need to guarantee sequential output, I'm using slice.
For a map in Golang, you can also refer to the Https://blog.golang.org/go-maps-in-action