I\'m trying to decode XML with golang, but the following code gives an empty struct
Anyone can help?
When I run the following code, I always get
You need to export your struct fields as per https://golang.org/pkg/encoding/xml/#Unmarshal
Because Unmarshal uses the reflect package, it can only assign to exported (upper case) fields. Unmarshal uses a case-sensitive comparison to match XML element names to tag values and struct field names.
e.g.
type Proto struct {
XMLName xml.Name `xml:"field"`
Name string `xml:"name,attr"`
Shownameg string `xml:"showname,attr"`
Fields []Field
}