【发布时间】:2021-06-06 15:17:40
【问题描述】:
我正在尝试将死的简单 yaml 配置文件映射到带有 this 包的结构,但没有成功。
config.yaml
Drivers:
- "/Volumes/V1"
- "/Volumes/V2"
去
type Iconfig struct {
Drivers []string `yaml:"Drivers,flow"`
}
iconfig := Iconfig{}
uerr := yaml.UnmarshalStrict(config_yaml, iconfig)
uerr:
panic: reflect: reflect.Value.Set using unaddressable value [recovered]
panic: reflect: reflect.Value.Set using unaddressable value
fmt.Println(string(config_yaml)):
Drivers:
- "/Volumes/V1"
- "/Volumes/V2"
为什么"/Volumes/V1" 被认为是不可寻址的值?
【问题讨论】: