mirror of
https://github.com/rclone/rclone.git
synced 2025-07-11 14:30:44 +02: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:
@ -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
|
||||
|
Reference in New Issue
Block a user