集合
package main
import "fmt"
func main() {
//如果不初始化 map,那么就会创建一个 nil map。nil map 不能用来存放键值对
s := map[string]string{}
s["name"] = "zhusy"
s["addr"] = "Hubei"
for k, v := range s {
fmt.Println(k, v)
}
var s1 map[string]string
s1 = make(map[string]string)
s1["name"] = "fuTian"
s1["addr"] = "HuBei"
for k := range s1 {
fmt.Println(s1[k])
}
s2 := make(map[string]string)
s2["name"] = "fuTian"
s2["addr"] = "HuBei"
for k, v := range s2 {
fmt.Println(k, v)
}
}