forked from TrueCloudLab/rclone
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:
parent
97328e5755
commit
e43b5ce5e5
233 changed files with 1673 additions and 1695 deletions
|
@ -5,9 +5,8 @@ import (
|
|||
cryptorand "crypto/rand"
|
||||
"encoding/base64"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
mathrand "math/rand"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// StringFn create a random string for test purposes using the random
|
||||
|
@ -53,10 +52,10 @@ func Password(bits int) (password string, err error) {
|
|||
var pw = make([]byte, bytes)
|
||||
n, err := cryptorand.Read(pw)
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "password read failed")
|
||||
return "", fmt.Errorf("password read failed: %w", err)
|
||||
}
|
||||
if n != bytes {
|
||||
return "", errors.Errorf("password short read: %d", n)
|
||||
return "", fmt.Errorf("password short read: %d", n)
|
||||
}
|
||||
password = base64.RawURLEncoding.EncodeToString(pw)
|
||||
return password, nil
|
||||
|
@ -72,7 +71,7 @@ func Seed() error {
|
|||
var seed int64
|
||||
err := binary.Read(cryptorand.Reader, binary.LittleEndian, &seed)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to read random seed")
|
||||
return fmt.Errorf("failed to read random seed: %w", err)
|
||||
}
|
||||
mathrand.Seed(seed)
|
||||
return nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue