1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| //字面量初始化
hash1 := map[string]int{
"1": 2,
"3": 4,
"5": 6,
}
//make初始化
hash2 := make(map[string]int, 3)
hash2["1"] = 2
hash2["3"] = 4
hash2["5"] = 6
//取值
_ = hash1[key]
//for 遍历
for k, v := range hash2 {
// k, v
}
// delete
hash1[key] = value
hash1[key] = newValue
delete(hash, key)
|