10 Golang map的正确使用姿势
var userInfo = make([]map[string]string,3,3)
fmt.Println(userInfo[0])//map[]
fmt.Println(userInfo[0] == nil)//true
if userInfo[0] == nil {
userInfo[0] = make(map[string]string)
userInfo[0]["username"] = "张三"
}
if userInfo[1] == nil {
userInfo[1] = make(map[string]string)
userInfo[1]["userName"] = "李四"
}
fmt.Println(userInfo)
//[map[username:张三] map[username:李四] map[]]