根据Go中的XML模式验证XML文档

How do you read an XML document in Go and validate it against an XML schema?

A start vouwld be to use the project metaleap/go-xsd, which can generate Go "XML wrapper" package sources for specified XSD schema URIs.

Each generated wrapper package contains the type structures required to easily xml.Unmarshal() an XML document based on that XSD.

It means that if you are not able to unmarshall an xml document using those generated classes (based on a specific XML schema), that xml document isn't a valid one (for that XML schema).