From e3b3c08e62f07c75426536c3407dfebc4b71405a Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 30 Nov 2017 20:41:00 -0500 Subject: use github.com/pkg/errors --- util.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'util.go') diff --git a/util.go b/util.go index dbb7d70..39bf2bd 100644 --- a/util.go +++ b/util.go @@ -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 { -- cgit v1.2.3