package main import "fmt" func main() { m := map[string]string{ "name": "fenghuo", "course": "golang", "quality": "good", } m2 := make(map[string]int) //m2 ==empty map var m3 map[string]int //m3==nil fmt.Println(m, m2, m3) }
//注意m2的值为empty map ,m3 的值为nil
打印结果
GOPATH=C:\Users\dell\go #gosetup
"C:\Program Files\Go\bin\go.exe" build -o C:\Users\dell\AppData\Local\Temp\GoLand\___go_build_hello_src_test__1_.exe C:\Users\dell\Desktop\go\src\test\maps.go #gosetup
C:\Users\dell\AppData\Local\Temp\GoLand\___go_build_hello_src_test__1_.exe
map[course:golang name:fenghuo quality:good] map[] map[]
Process finished with the exit code 0