background

There was a BUG in the business code. I forgot to save the scene and the text description. I drew the 2d line chart by myself and found the time displayed on the horizontal axis was out of order

argument

The debugging code is as follows:

func main() {
	a := make(map[string]string)
	a["a"] = "a"
	a["b"] = "b"
	a["c"] = "c"
	a["d"] = "d"
	for k, v := range a {
		fmt.Println(k + ":" + v)
	}
}
Copy the code

Multiple running results:

why

Golang source code in map traversal position control using random numbers, portals

Why is it designed this way?

To solve

  • import sort
  • Maintaining an array

reference

Blog.csdn.net/slvher/arti…

www.cnblogs.com/JoZSM/p/117…

Cloud.tencent.com/developer/a…

www.cnblogs.com/qcrao-2018/…

Github.com/golang/go/b…