// MapFunc02 ... Map CRUD FUNC MapFunc02 () { m: = the make (Map [ String ] String ) m [ " 11111 " ] = " insects " m [ " 22222 " ] = " Brassica " m [ " 33333 " ] = " small wind " fmt.Println ( " m = " , m) // If no map key "44444", the new m [ " 44444 " ] = "Little Frog " fmt.Println ( " m = " , m) // if the key "11111" map in to modify m [ " 11111 " ] = " insects * " fmt.Println ( " m = " , m) // remove the map key "22222" data delete (m, " 22222 " ) fmt.Println ( " m = " , m) // delete all the data in the map // 1, through all key, individually remove // 2, the new space re-make direct // m = make (map [String] String) // lookup keys [ "11111" val, ok := m["11111"] if ok { fmt.Println("11111", val) } else { fmt.Println("没有11111") } }
operation result