由于某种原因,我收到以下错误./execTest.go:24: template.datacenter undefined (type map[string]string has no field or method datacenter)./execTest.go:25: template.datacenter undefined (type map[string]string has no field or method datacenter)这是我的 Go 代码package mainimport ( "fmt")var template map[string]stringfunc main() { template := map[string]string{ "cluster": "", "datacenter": "The_Datacenter", "host": "", "password": "", "username": "", "vm_name": "", } args := []string{ "--acceptAllEulas", "--compress=9", } if template.datacenter != "" { args = append(args, fmt.Sprintf("--datacenter=%s", template.datacenter)) } fmt.Println(template)}
1 回答
- 1 回答
- 0 关注
- 277 浏览
添加回答
举报
0/150
提交
取消