mirror of
https://github.com/rclone/rclone.git
synced 2025-08-16 00:28:09 +02:00
Replace deprecated ioutil
As of Go 1.16, the same functionality is now provided by package io or package os, and those implementations should be preferred in new code.
This commit is contained in:
committed by
Nick Craig-Wood
parent
776e5ea83a
commit
5d6b8141ec
@ -17,7 +17,6 @@ import (
|
||||
"encoding/pem"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@ -311,7 +310,7 @@ func (s *server) Close() {
|
||||
}
|
||||
|
||||
func loadPrivateKey(keyPath string) (ssh.Signer, error) {
|
||||
privateBytes, err := ioutil.ReadFile(keyPath)
|
||||
privateBytes, err := os.ReadFile(keyPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to load private key: %w", err)
|
||||
}
|
||||
@ -326,7 +325,7 @@ func loadPrivateKey(keyPath string) (ssh.Signer, error) {
|
||||
// the public key of a received connection
|
||||
// with the entries in the authorized_keys file.
|
||||
func loadAuthorizedKeys(authorizedKeysPath string) (authorizedKeysMap map[string]struct{}, err error) {
|
||||
authorizedKeysBytes, err := ioutil.ReadFile(authorizedKeysPath)
|
||||
authorizedKeysBytes, err := os.ReadFile(authorizedKeysPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to load authorized keys: %w", err)
|
||||
}
|
||||
@ -369,7 +368,7 @@ func makeRSASSHKeyPair(bits int, pubKeyPath, privateKeyPath string) (err error)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return ioutil.WriteFile(pubKeyPath, ssh.MarshalAuthorizedKey(pub), 0644)
|
||||
return os.WriteFile(pubKeyPath, ssh.MarshalAuthorizedKey(pub), 0644)
|
||||
}
|
||||
|
||||
// makeECDSASSHKeyPair make a pair of public and private keys for ECDSA SSH access.
|
||||
@ -401,7 +400,7 @@ func makeECDSASSHKeyPair(pubKeyPath, privateKeyPath string) (err error) {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return ioutil.WriteFile(pubKeyPath, ssh.MarshalAuthorizedKey(pub), 0644)
|
||||
return os.WriteFile(pubKeyPath, ssh.MarshalAuthorizedKey(pub), 0644)
|
||||
}
|
||||
|
||||
// makeEd25519SSHKeyPair make a pair of public and private keys for Ed25519 SSH access.
|
||||
@ -433,5 +432,5 @@ func makeEd25519SSHKeyPair(pubKeyPath, privateKeyPath string) (err error) {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return ioutil.WriteFile(pubKeyPath, ssh.MarshalAuthorizedKey(pub), 0644)
|
||||
return os.WriteFile(pubKeyPath, ssh.MarshalAuthorizedKey(pub), 0644)
|
||||
}
|
||||
|
Reference in New Issue
Block a user