Yaml: 不支持“继承”结构

创建于 2014-09-23  ·  3评论  ·  资料来源: go-yaml/yaml

鉴于这些结构:

    type Path struct {
        Description string
        Paths       map[string]Path
    }

    type Top struct {
        Title       string
        Path
    }

我应该能够像这样解组 YAML:

  title: Recursive
  paths:
    a:
      paths:
        b:
          paths:
            c:
              description: Bottom

这可行,但应该与上述相同:

    type Path struct {
        Description string
        Paths       map[string]Path
    }

    type Top struct {
        Title       string
        Paths    map[string]Path
    }

最有用的评论

根据文档,您需要,inline标志:

http://gopkg.in/yaml.v2#Marshal

您可以在普通字段和匿名字段上使用该标志。

所有3条评论

根据文档,您需要,inline标志:

http://gopkg.in/yaml.v2#Marshal

您可以在普通字段和匿名字段上使用该标志。

:+1: 抱歉,我知道:RTFM @rnix :gun:

没问题。 ;-)

并感谢您提交问题。 它们很可能是有效的问题。

此页面是否有帮助?
0 / 5 - 0 等级