go语言之结构体struct继承

// 错误的继承
type XMLData struct {
    ID       int
    XMLNodes XMLNodes
}

// 正确的继承
type XMLData struct {
    ID       int
    XMLNodes
}

// 被继承的struct
type XMLNodes struct {
    Footer1     string `xml:"footer1"`
    Footer2     string `xml:"footer2"`
    Footer3     string `xml:"footer3"`
}
posted @ 2021-04-07 16:11  vaen  阅读(822)  评论(0)    收藏  举报