1. 程式人生 > >GO語言學習:map官方解釋

GO語言學習:map官方解釋

This variable m is a map of string keys to int values:

var m map[string]int
Map types are reference types, like pointers or slices,

and so the value of m above is nil; it doesn't point to an initialized map.

A nil map behaves like an empty map when reading,

but attempts to write to a nil map will cause a runtime panic;

don't do that. To initialize a map, use the built in make function:

m = make(map[string]int)