Skip to content

Instantly share code, notes, and snippets.

@mkock
mkock / concurrent-xml-parser.go
Last active April 27, 2018 12:29
Concurrent version of the DMR XML parser in Go.
// Same data structures as before.
// ParseExcerpt parses XML file using XML decoding.
func (p *XMLParser) ParseExcerpt(id int, lines <-chan []string, parsed chan<- string, done chan<- int) {
proc := 0 // How many excerpts did we process?
var stat vehicleStat
for excerpt := range lines {
if err := xml.Unmarshal([]byte(strings.Join(excerpt, "\n")), &stat); err != nil {
panic(err) // We _could_ skip it, but it's better to halt execution here.
}