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:
+5
-6
@@ -16,7 +16,6 @@ import (
|
||||
"github.com/atotto/clipboard"
|
||||
runewidth "github.com/mattn/go-runewidth"
|
||||
termbox "github.com/nsf/termbox-go"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rclone/rclone/cmd"
|
||||
"github.com/rclone/rclone/cmd/ncdu/scan"
|
||||
"github.com/rclone/rclone/fs"
|
||||
@@ -314,7 +313,7 @@ func (u *UI) Draw() error {
|
||||
// Plot
|
||||
err := termbox.Clear(termbox.ColorDefault, termbox.ColorDefault)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to clear screen")
|
||||
return fmt.Errorf("failed to clear screen: %w", err)
|
||||
}
|
||||
|
||||
// Header line
|
||||
@@ -432,7 +431,7 @@ func (u *UI) Draw() error {
|
||||
}
|
||||
err = termbox.Flush()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to flush screen")
|
||||
return fmt.Errorf("failed to flush screen: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -742,7 +741,7 @@ func NewUI(f fs.Fs) *UI {
|
||||
func (u *UI) Show() error {
|
||||
err := termbox.Init()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "termbox init")
|
||||
return fmt.Errorf("termbox init: %w", err)
|
||||
}
|
||||
defer termbox.Close()
|
||||
|
||||
@@ -766,7 +765,7 @@ outer:
|
||||
//Reset()
|
||||
err := u.Draw()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "draw failed")
|
||||
return fmt.Errorf("draw failed: %w", err)
|
||||
}
|
||||
var root *scan.Dir
|
||||
select {
|
||||
@@ -775,7 +774,7 @@ outer:
|
||||
u.setCurrentDir(root)
|
||||
case err := <-errChan:
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "ncdu directory listing")
|
||||
return fmt.Errorf("ncdu directory listing: %w", err)
|
||||
}
|
||||
u.listing = false
|
||||
case <-updated:
|
||||
|
||||
@@ -3,10 +3,10 @@ package scan
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"path"
|
||||
"sync"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rclone/rclone/fs"
|
||||
"github.com/rclone/rclone/fs/walk"
|
||||
)
|
||||
@@ -185,7 +185,7 @@ func Scan(ctx context.Context, f fs.Fs) (chan *Dir, chan error, chan struct{}) {
|
||||
var ok bool
|
||||
parent, ok = parents[parentPath]
|
||||
if !ok {
|
||||
errChan <- errors.Errorf("couldn't find parent for %q", dirPath)
|
||||
errChan <- fmt.Errorf("couldn't find parent for %q", dirPath)
|
||||
}
|
||||
}
|
||||
d := newDir(parent, dirPath, entries, err)
|
||||
@@ -202,7 +202,7 @@ func Scan(ctx context.Context, f fs.Fs) (chan *Dir, chan error, chan struct{}) {
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
errChan <- errors.Wrap(err, "ncdu listing failed")
|
||||
errChan <- fmt.Errorf("ncdu listing failed: %w", err)
|
||||
}
|
||||
errChan <- nil
|
||||
}()
|
||||
|
||||
Reference in New Issue
Block a user