Remove github.com/pkg/errors and replace with std library version

This is possible now that we no longer support go1.12 and brings
rclone into line with standard practices in the Go world.

This also removes errors.New and errors.Errorf from lib/errors and
prefers the stdlib errors package over lib/errors.
This commit is contained in:
Nick Craig-Wood
2021-11-04 10:12:57 +00:00
parent 97328e5755
commit e43b5ce5e5
233 changed files with 1673 additions and 1695 deletions

View File

@@ -7,6 +7,7 @@ package bisync_test
import (
"bytes"
"context"
"errors"
"flag"
"fmt"
"io/ioutil"
@@ -36,7 +37,6 @@ import (
"github.com/rclone/rclone/lib/atexit"
"github.com/rclone/rclone/lib/random"
"github.com/pkg/errors"
"github.com/pmezard/go-difflib/difflib"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -541,7 +541,7 @@ func (b *bisyncTest) runTestStep(ctx context.Context, line string) (err error) {
case "bisync":
return b.runBisync(ctx, args[1:])
default:
return errors.Errorf("unknown command: %q", args[0])
return fmt.Errorf("unknown command: %q", args[0])
}
}
@@ -635,7 +635,7 @@ func (b *bisyncTest) runBisync(ctx context.Context, args []string) (err error) {
fs1 = addSubdir(b.path1, val)
fs2 = addSubdir(b.path2, val)
default:
return errors.Errorf("invalid bisync option %q", arg)
return fmt.Errorf("invalid bisync option %q", arg)
}
}
@@ -793,12 +793,12 @@ func touchFiles(ctx context.Context, dateStr string, f fs.Fs, dir, glob string)
date, err := time.ParseInLocation(touchDateFormat, dateStr, bisync.TZ)
if err != nil {
return files, errors.Wrapf(err, "invalid date %q", dateStr)
return files, fmt.Errorf("invalid date %q: %w", dateStr, err)
}
matcher, firstErr := filter.GlobToRegexp(glob, false)
if firstErr != nil {
return files, errors.Errorf("invalid glob %q", glob)
return files, fmt.Errorf("invalid glob %q", glob)
}
entries, firstErr := f.List(ctx, "")