summaryrefslogtreecommitdiff
path: root/util.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2017-11-30 20:41:00 -0500
committerLuke Shumaker <lukeshu@lukeshu.com>2017-11-30 20:41:00 -0500
commite3b3c08e62f07c75426536c3407dfebc4b71405a (patch)
tree9add249423816b9bc93f40694d921330243d6725 /util.go
parentdeb826c9c18f26652e565a013e2d00929c0b8a35 (diff)
use github.com/pkg/errors
Diffstat (limited to 'util.go')
-rw-r--r--util.go9
1 files changed, 5 insertions, 4 deletions
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 {