go list转map
func ListTOMap(ls []string) map[string]interface{} {
m := make(map[string]interface{})
for _, l := range ls {
if l != "" {
kv := strings.Split(l, "=")
fmt.Println(kv) //
if len(kv) == 2 {
m[kv[0]] = kv[1]
}
}
}
fmt.Println(m)
return m
}
//运行结果
/mnt/c/Users/Administrator/AppData/Local/Temp/GoLand/___111go_build_TestPrt_go_linux
[name yunhua]
[age 36]
map[age:36 name:yunhua]