Extract scanning ASCII files into a util package

This commit is contained in:
2018-03-18 05:04:46 +00:00
parent 4176ccd94f
commit 10e22d8428
5 changed files with 131 additions and 100 deletions

View File

@@ -3,6 +3,8 @@ package data
import (
"bytes"
"errors"
"ur.gs/chaos-gate/internal/util/asciiscan"
)
// Comments are `//`, start of line only, for accounting
@@ -13,11 +15,14 @@ var (
type Accounting map[string]string
func LoadAccounting(filename string) (Accounting, error) {
scanLines, err := fileToScanner(filename)
s, err := asciiscan.New(filename)
if err != nil {
return nil, err
}
defer s.Close()
scanLines := s.Bufio()
out := make(Accounting)
for scanLines.Scan() {