我想部分读取yaml,即解码Type/Description键,但将Sample定义结构的键-保留为纯字符串。目的是定义用于解码的测试数据集。
例子:
type: default
description: test data
sample:
some: # want
complex: # comments
- struct # included
我希望子键sample作为纯字符串返回。
我尝试使用带有解组器接口(gopkg.in/yaml.v2)的别名类型:
type plain string // implements UnmarshalYAML
但以:
panic: yaml: unmarshal errors:
line 4: cannot unmarshal !!map into []uint8
我找不到使用UnmarshalYAML自定义字符串类型或强制转换为字符串的简单方法?
白板的微信
LEATH