mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 23:18:15 -05:00
Replace ioutil with io and os (#10541)
* Replace ioutil with io and os * Fix build errors
This commit is contained in:
committed by
GitHub
parent
982de94428
commit
d2f4a8cc7c
@@ -8,7 +8,6 @@ import (
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -110,7 +109,7 @@ func decrypt(cliCtx *cli.Context) error {
|
||||
return errors.Wrapf(err, "could not check if path exists: %s", fullPath)
|
||||
}
|
||||
if isDir {
|
||||
files, err := ioutil.ReadDir(fullPath)
|
||||
files, err := os.ReadDir(fullPath)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "could not read directory: %s", fullPath)
|
||||
}
|
||||
@@ -224,7 +223,7 @@ func encrypt(cliCtx *cli.Context) error {
|
||||
// Reads the keystore file at the provided path and attempts
|
||||
// to decrypt it with the specified passwords.
|
||||
func readAndDecryptKeystore(fullPath, password string) error {
|
||||
file, err := ioutil.ReadFile(fullPath) // #nosec G304
|
||||
file, err := os.ReadFile(fullPath) // #nosec G304
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "could not read file at path: %s", fullPath)
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -77,7 +77,7 @@ func TestDecrypt(t *testing.T) {
|
||||
encodedKeystore, err := json.MarshalIndent(keystore, "", "\t")
|
||||
require.NoError(t, err)
|
||||
keystoreFilePath := filepath.Join(keystoresDir, "keystore.json")
|
||||
require.NoError(t, ioutil.WriteFile(
|
||||
require.NoError(t, os.WriteFile(
|
||||
keystoreFilePath, encodedKeystore, params.BeaconIoConfig().ReadWritePermissions),
|
||||
)
|
||||
|
||||
@@ -95,7 +95,7 @@ func TestDecrypt(t *testing.T) {
|
||||
require.NoError(t, decrypt(cliCtx))
|
||||
|
||||
require.NoError(t, w.Close())
|
||||
out, err := ioutil.ReadAll(r)
|
||||
out, err := io.ReadAll(r)
|
||||
require.NoError(t, err)
|
||||
|
||||
// We capture output from stdout.
|
||||
@@ -129,7 +129,7 @@ func TestEncrypt(t *testing.T) {
|
||||
require.NoError(t, encrypt(cliCtx))
|
||||
|
||||
require.NoError(t, w.Close())
|
||||
out, err := ioutil.ReadAll(r)
|
||||
out, err := io.ReadAll(r)
|
||||
require.NoError(t, err)
|
||||
|
||||
// We capture output from stdout.
|
||||
|
||||
Reference in New Issue
Block a user