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-07 11:53:30 +00:00
parent 97328e5755
commit e43b5ce5e5
233 changed files with 1673 additions and 1695 deletions
+6 -7
View File
@@ -13,7 +13,6 @@ import (
"strings"
"time"
"github.com/pkg/errors"
"github.com/rclone/rclone/fs"
"github.com/rclone/rclone/fs/fshttp"
"golang.org/x/net/publicsuffix"
@@ -122,12 +121,12 @@ func (ca *CookieAuth) Cookies(ctx context.Context) (*CookieResponse, error) {
func (ca *CookieAuth) getSPCookie(conf *SharepointSuccessResponse) (*CookieResponse, error) {
spRoot, err := url.Parse(ca.endpoint)
if err != nil {
return nil, errors.Wrap(err, "Error while constructing endpoint URL")
return nil, fmt.Errorf("error while constructing endpoint URL: %w", err)
}
u, err := url.Parse(spRoot.Scheme + "://" + spRoot.Host + "/_forms/default.aspx?wa=wsignin1.0")
if err != nil {
return nil, errors.Wrap(err, "Error while constructing login URL")
return nil, fmt.Errorf("error while constructing login URL: %w", err)
}
// To authenticate with davfs or anything else we need two cookies (rtFa and FedAuth)
@@ -143,7 +142,7 @@ func (ca *CookieAuth) getSPCookie(conf *SharepointSuccessResponse) (*CookieRespo
// Send the previously acquired Token as a Post parameter
if _, err = client.Post(u.String(), "text/xml", strings.NewReader(conf.Body.Token)); err != nil {
return nil, errors.Wrap(err, "Error while grabbing cookies from endpoint: %v")
return nil, fmt.Errorf("error while grabbing cookies from endpoint: %w", err)
}
cookieResponse := CookieResponse{}
@@ -171,7 +170,7 @@ func (ca *CookieAuth) getSPToken(ctx context.Context) (conf *SharepointSuccessRe
buf := &bytes.Buffer{}
if err := t.Execute(buf, reqData); err != nil {
return nil, errors.Wrap(err, "Error while filling auth token template")
return nil, fmt.Errorf("error while filling auth token template: %w", err)
}
// Create and execute the first request which returns an auth token for the sharepoint service
@@ -184,7 +183,7 @@ func (ca *CookieAuth) getSPToken(ctx context.Context) (conf *SharepointSuccessRe
client := fshttp.NewClient(ctx)
resp, err := client.Do(req)
if err != nil {
return nil, errors.Wrap(err, "Error while logging in to endpoint")
return nil, fmt.Errorf("error while logging in to endpoint: %w", err)
}
defer fs.CheckClose(resp.Body, &err)
@@ -209,7 +208,7 @@ func (ca *CookieAuth) getSPToken(ctx context.Context) (conf *SharepointSuccessRe
}
if err != nil {
return nil, errors.Wrap(err, "Error while reading endpoint response")
return nil, fmt.Errorf("error while reading endpoint response: %w", err)
}
return
}