草庐IT

GoYAML - 将字符串输入转换为 Unmarshal 上的类型

我有一个像这样为我的Yaml文件定义的结构:typeServicestruct{ServiceNamestring`yaml:"service_name"`PipelineTypePipelineType`yaml:"pipeline_type"`}在文件中,这个结构以字符串的形式出现:service_name:servicepipeline_type:app我的类型是这样定义的://PipelineTypePipelineTypestypePipelineTypestruct{Valuestring}var(AppPipeline=PipelineType{"app"}...)由于类

goyaml 将字符串转换为 int 常量

假设我们有如下go代码typeSectionTypeintconst(HeaderSectionType=iotaFooterBody)varsectionTypeNames=map[string]SectionType{"header":Header"footer":Footer"body":Body}typePagestruct{Sections:[]SectionType`yaml:"sections"`}我们有以下yamlpage1:-header-body有没有办法让goyaml将我们反序列化Page结构? 最佳答案 go

GoYAML 结构 slice

我正在尝试学习goyaml,但在尝试从yaml生成slice时遇到了一些问题。我可以将我的结构编码到这个示例yaml中,但我无法将相同的yaml解编回结构中。input:file:-file:stdinwebservice:-port:"0000"address:0.0.0.0processing:regex:-regex:^(this)*mapping:(1)thingoutput:file:-file:stdoutwebservice:-port:"0000"address:0.0.0.0结构:typeConfigurationstruct{InputioInstanceProce