How to run a suite of checks on an xml file? Each check is a method that returns 2 strings: it's name and pass or fail. Using xmlquery. I tried putting all the methods in an interface but can't figure out how to iterate.
In this code sample, trying to get something to work for comment "WANT":
package main
import (
"fmt"
"github.com/antchfx/xmlquery"
)
type node xmlquery.Node
type XmlChecks interface {
checkUTC() (string, string)
checkSugPresDel() (string, string)
checkStartNum() (string, string)
// ... there will be many
}
type XmlVerify struct {
doc node
}
func (xver XmlVerify) checkUTC() (string, string) {
//TBD
return "cUTC", "pass"
}
func (xver XmlVerify) checkSugPresDel() (string, string) {
//TBD
return "cSugPresDel", "pass"
}
func (xver XmlVerify) checkStartNum() (string, string) {
//TBD
return "cStartNum", "pass"
}
func main() {
var vrfy XmlVerify
vrfy.doc, _ := xmlquery.Parse("myfile.xml")
for each_method := range "all the methods in vrfy.XmlChecks" { //<--WANT
fmt.Printf("%s %s\n", vrfy.each_method()) //<--WANT
}
}