aboutsummaryrefslogtreecommitdiff
path: root/chksum
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2017-05-03 15:02:31 +0200
committerDimitri Sokolyuk <demon@dim13.org>2017-05-03 15:02:31 +0200
commitcd6427deddb781a981a9db6f847dcf50178c601b (patch)
tree6c65d4474d62d989b42a09c7a3c5323c771113c4 /chksum
parent1b4ed34a5ab493f14494304904da5a553cc4980b (diff)
Add parse bytes
Diffstat (limited to 'chksum')
-rw-r--r--chksum/chksum.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/chksum/chksum.go b/chksum/chksum.go
index e21a2a8..2eefb52 100644
--- a/chksum/chksum.go
+++ b/chksum/chksum.go
@@ -49,10 +49,15 @@ func ParseFile(fname string) (Checklist, error) {
return nil, err
}
defer fd.Close()
- return Parse(fd)
+ return parse(fd)
}
-func Parse(r io.Reader) (Checklist, error) {
+func Parse(data []byte) (Checklist, error) {
+ r := bytes.NewReader(data)
+ return parse(r)
+}
+
+func parse(r io.Reader) (Checklist, error) {
var checklist Checklist
re := regexp.MustCompile(`(\w+) \(([^)]+)\) = (\w+)`)
scanner := bufio.NewScanner(r)