Original text: yourbasic.org/golang/gotc…

Why did this program cause Panic?

var m map[string]float64
m["pi"] = 3.1416
Copy the code
panic: assignment to entry in nil map
Copy the code

answer

Before adding elements to a map, you need to initialize the map using either the make function or a map literal.