From 69558c196dc673d28d0e496afea350249c963787 Mon Sep 17 00:00:00 2001 From: Greg Colburn Date: Fri, 27 Nov 2015 07:46:01 -0700 Subject: [PATCH] Switched from int to string for date epochs, thanks to Y! trailing spaces. Change-Id: I81d6f5e42e63dafbbb7f3d64ced588dc32f4c381 --- dmarc.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/dmarc.go b/dmarc.go index d6b27b6..66f74c5 100644 --- a/dmarc.go +++ b/dmarc.go @@ -9,8 +9,9 @@ import ( func main() { type DateRange struct { - Begin int `xml:"begin"` - End int `xml:"end"` + // TODO: should be int but Y! trailing spaces + Begin string `xml:"begin"` + End string `xml:"end"` } type ReportMetadata struct { @@ -71,7 +72,7 @@ func main() { Record []Record `xml:"record"` } - xmlFile, err := os.Open("/Users/gcolburn/go/src/github.com/gc1code/dmarcparser/samples/google.xml") // For read access. + xmlFile, err := os.Open("/Users/gcolburn/go/src/github.com/gc1code/dmarcparser/samples/yahoo.xml") // For read access. if err != nil { fmt.Printf("os error: %v", err) return @@ -90,9 +91,12 @@ func main() { case xml.StartElement: inElement = se.Name.Local if inElement == "feedback" { - var f FeedbackReport + f := FeedbackReport{} - decoder.DecodeElement(&f, &se) + xmlerr := decoder.DecodeElement(&f, &se) + if xmlerr != nil { + fmt.Printf("decode error: %v", xmlerr) + } fmt.Printf("XMLName: %#v\n", f) } default: