mirror of
https://github.com/rclone/rclone.git
synced 2025-12-11 22:14:05 +01:00
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:
@@ -3,6 +3,7 @@ package docker
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math/rand"
|
||||
"os"
|
||||
@@ -13,7 +14,6 @@ import (
|
||||
"time"
|
||||
|
||||
sysdnotify "github.com/iguanesolutions/go-systemd/v5/notify"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/rclone/rclone/cmd/mountlib"
|
||||
"github.com/rclone/rclone/fs"
|
||||
@@ -44,12 +44,12 @@ func NewDriver(ctx context.Context, root string, mntOpt *mountlib.Options, vfsOp
|
||||
cacheDir := config.GetCacheDir()
|
||||
err := file.MkdirAll(cacheDir, 0700)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to create cache directory: %s", cacheDir)
|
||||
return nil, fmt.Errorf("failed to create cache directory: %s: %w", cacheDir, err)
|
||||
}
|
||||
|
||||
//err = file.MkdirAll(root, 0755)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to create mount root: %s", root)
|
||||
return nil, fmt.Errorf("failed to create mount root: %s: %w", root, err)
|
||||
}
|
||||
|
||||
// setup driver state
|
||||
@@ -72,7 +72,7 @@ func NewDriver(ctx context.Context, root string, mntOpt *mountlib.Options, vfsOp
|
||||
// restore from saved state
|
||||
if !forgetState {
|
||||
if err = drv.restoreState(ctx); err != nil {
|
||||
return nil, errors.Wrap(err, "failed to restore state")
|
||||
return nil, fmt.Errorf("failed to restore state: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ func NewDriver(ctx context.Context, root string, mntOpt *mountlib.Options, vfsOp
|
||||
|
||||
// notify systemd
|
||||
if err := sysdnotify.Ready(); err != nil {
|
||||
return nil, errors.Wrap(err, "failed to notify systemd")
|
||||
return nil, fmt.Errorf("failed to notify systemd: %w", err)
|
||||
}
|
||||
|
||||
return drv, nil
|
||||
@@ -323,7 +323,7 @@ func (drv *Driver) saveState() error {
|
||||
|
||||
data, err := json.Marshal(state)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to marshal state")
|
||||
return fmt.Errorf("failed to marshal state: %w", err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
@@ -335,7 +335,7 @@ func (drv *Driver) saveState() error {
|
||||
}
|
||||
time.Sleep(time.Duration(rand.Intn(100)) * time.Millisecond)
|
||||
}
|
||||
return errors.Wrap(err, "failed to save state")
|
||||
return fmt.Errorf("failed to save state: %w", err)
|
||||
}
|
||||
|
||||
// restoreState recreates volumes from saved driver state
|
||||
|
||||
Reference in New Issue
Block a user