package main
import"fmt"type Vertex struct{
Lat, Long float64}var m =map[string]Vertex{"Bell Labs":{40.68433,-74.39967},"Google":{37.42202,-122.08408},}funcmain(){
fmt.Println(m)}
遍历
// 遍历键值对for k, v :=range scene {
fmt.Println(k, v)}// 遍历键for k :=range scene {
fmt.Println(k)}// 遍历值for_, v :=range scene {
fmt.Println(v)}
if_, ok :=map[key]; ok {// 存在}if_, ok :=map[key];!ok {// 不存在}
safety discussion
it’s fine to search not existed key in map, it will return a zero value of the value’s type
cannot get the address of the map’s element(like _ := &mapA[1]). cus the growth of a map might cause a rehashing of this map into new storage location.