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

@@ -15,7 +15,6 @@ import (
"runtime/debug"
"strings"
"github.com/pkg/errors"
"github.com/rclone/rclone/fs"
"github.com/rclone/rclone/fs/accounting"
"github.com/rclone/rclone/fs/config/configfile"
@@ -91,23 +90,23 @@ func RPC(method string, input string) (output string, status int) {
// create a buffer to capture the output
err := json.NewDecoder(strings.NewReader(input)).Decode(&in)
if err != nil {
return writeError(method, in, errors.Wrap(err, "failed to read input JSON"), http.StatusBadRequest)
return writeError(method, in, fmt.Errorf("failed to read input JSON: %w", err), http.StatusBadRequest)
}
// Find the call
call := rc.Calls.Get(method)
if call == nil {
return writeError(method, in, errors.Errorf("couldn't find method %q", method), http.StatusNotFound)
return writeError(method, in, fmt.Errorf("couldn't find method %q", method), http.StatusNotFound)
}
// TODO: handle these cases
if call.NeedsRequest {
return writeError(method, in, errors.Errorf("method %q needs request, not supported", method), http.StatusNotFound)
return writeError(method, in, fmt.Errorf("method %q needs request, not supported", method), http.StatusNotFound)
// Add the request to RC
//in["_request"] = r
}
if call.NeedsResponse {
return writeError(method, in, errors.Errorf("method %q need response, not supported", method), http.StatusNotFound)
return writeError(method, in, fmt.Errorf("method %q need response, not supported", method), http.StatusNotFound)
//in["_response"] = w
}