605 B
605 B
PROBLEM
summarize()knows a lot about the internals of theparser.- coupled to the
parser.
- coupled to the
SOLUTION
-
remove:
parser.gosumanddomainsfields- remove:
parser.go/newParser() - change:
parser.go/parse(p *parser) error->parse() ([]result, error) - initialize:
suminsideparse() - remove:
update() - call:
sumupdate in theparse() - collect the grouped results and return them from
parser()
- remove:
-
summarize(p *parser)->summarize([]result) -
in
summarize()sort.Slice- range over
[]result
-
main.go- just:
res, err := parse()
- just: