import (
"bufio"
- "errors"
"io"
"strings"
)
scanner *bufio.Scanner
}
+type FormatErr string
+
+func (err FormatErr) Error() string {
+ return string(err)
+}
+
// Create Reader for iterating through the records. It uses
// bufio.Scanner, so can read more than currently parsed records take.
func NewReader(r io.Reader) *Reader {
name, line = getKeyValue(text)
if name == "" {
- return fields, errors.New("invalid field format")
+ return fields, FormatErr("invalid field format")
}
if len(line) > 0 && line[len(line)-1] == '\\' {
}
}
if continuation {
- return fields, errors.New("left continuation")
+ return fields, FormatErr("left continuation")
}
if len(lines) > 0 {
fields = append(fields, Field{name, strings.Join(lines, "")})