diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2017-11-30 20:41:00 -0500 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2017-11-30 20:41:00 -0500 |
commit | e3b3c08e62f07c75426536c3407dfebc4b71405a (patch) | |
tree | 9add249423816b9bc93f40694d921330243d6725 /util.go | |
parent | deb826c9c18f26652e565a013e2d00929c0b8a35 (diff) |
use github.com/pkg/errors
Diffstat (limited to 'util.go')
-rw-r--r-- | util.go | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -1,9 +1,10 @@ package libfastimport import ( - "fmt" "strconv" "strings" + + "github.com/pkg/errors" ) func trimLinePrefix(line string, prefix string) string { @@ -19,19 +20,19 @@ func trimLinePrefix(line string, prefix string) string { func parse_data(line string) (data string, err error) { nl := strings.IndexByte(line, '\n') if nl < 0 { - return "", fmt.Errorf("data: expected newline: %v", data) + return "", errors.Errorf("data: expected newline: %v", data) } head := line[:nl+1] rest := line[nl+1:] if !strings.HasPrefix(head, "data ") { - return "", fmt.Errorf("data: could not parse: %v", data) + return "", errors.Errorf("data: could not parse: %v", data) } if strings.HasPrefix(head, "data <<") { // Delimited format delim := trimLinePrefix(head, "data <<") suffix := "\n" + delim + "\n" if !strings.HasSuffix(rest, suffix) { - return "", fmt.Errorf("data: did not find suffix: %v", suffix) + return "", errors.Errorf("data: did not find suffix: %v", suffix) } data = strings.TrimSuffix(rest, suffix) } else { |