package main import ( "time" ) var transactionTemplate = ` {{ range . }} {{ .Date.Format "2006-01-02" }} {{ .VendorName }} {{ .Asset }} {{ .TrnAmt }} {{ .Currency }} {{ .Expense }} {{ end }} ` type transaction struct { Date time.Time `xml:"Date"` TrnAmt float64 `xml:"Amount"` Asset string `xml:"Asset"` Expense string `xml:"Expense,omitempty"` VendorName string `xml:"VendorName,omitempty"` Currency string `xml:"Currency"` } type byDate []transaction func (b byDate) Len() int { return len(b) } func (b byDate) Less(i, j int) bool { return b[i].Date.Before(b[j].Date) } func (b byDate) Swap(i, j int) { b[i], b[j] = b[j], b[i] }