Remove ioutil.

This commit is contained in:
Jim McDonald
2022-12-12 11:38:07 +00:00
parent 2bd8fdee5e
commit d5fc8fed37
11 changed files with 22 additions and 29 deletions

View File

@@ -16,7 +16,7 @@ package accountimport
import (
"context"
"encoding/hex"
"io/ioutil"
"os"
"strings"
"time"
@@ -115,7 +115,7 @@ func obtainKeystore(input string) ([]byte, error) {
data = []byte(input)
} else {
// Assume it's a path to JSON
data, err = ioutil.ReadFile(input)
data, err = os.ReadFile(input)
if err != nil {
return nil, errors.Wrap(err, "failed to find deposit data file")
}

View File

@@ -1,4 +1,4 @@
// Copyright © 2019-2021 Weald Technology Limited.
// Copyright © 2019-2022 Weald Technology Limited.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@@ -17,7 +17,6 @@ import (
"bytes"
"encoding/hex"
"fmt"
"io/ioutil"
"os"
"strings"
@@ -64,7 +63,7 @@ In quiet mode this will return 0 if the the data is verified correctly, otherwis
data = []byte(depositVerifyData)
default:
// Assume it's a path to JSON.
data, err = ioutil.ReadFile(depositVerifyData)
data, err = os.ReadFile(depositVerifyData)
errCheck(err, "Failed to read deposit data file")
if data[0] == '{' {
data = []byte("[" + string(data) + "]")
@@ -155,7 +154,7 @@ func validatorPubKeysFromInput(input string) (map[[48]byte]bool, error) {
pubKeys[key] = true
} else {
// Assume it's a path to a file of public keys.
data, err = ioutil.ReadFile(input)
data, err = os.ReadFile(input)
if err != nil {
return nil, errors.Wrap(err, "failed to find public key file")
}

View File

@@ -1,4 +1,4 @@
// Copyright © 2020 Weald Technology Trading
// Copyright © 2020, 2022 Weald Technology Trading
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@@ -19,7 +19,6 @@ import (
"encoding/hex"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"strings"
@@ -97,7 +96,7 @@ func obtainExitData(input string) (*util.ValidatorExitData, error) {
data = []byte(input)
} else {
// Assume it's a path to JSON
data, err = ioutil.ReadFile(input)
data, err = os.ReadFile(input)
if err != nil {
return nil, errors.Wrap(err, "failed to find deposit data file")
}

View File

@@ -18,7 +18,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"os"
"strconv"
@@ -125,7 +125,7 @@ func graphData(network string, validatorPubKey []byte) (uint64, spec.Gwei, error
return 0, 0, errors.Wrap(err, "failed to check if there is already a deposit for this validator")
}
defer graphResp.Body.Close()
body, err := ioutil.ReadAll(graphResp.Body)
body, err := io.ReadAll(graphResp.Body)
if err != nil {
return 0, 0, errors.Wrap(err, "bad information returned from existing deposit check")
}

View File

@@ -15,7 +15,6 @@ package walletdelete
import (
"context"
"io/ioutil"
"os"
"testing"
"time"
@@ -31,7 +30,7 @@ import (
func TestProcess(t *testing.T) {
require.NoError(t, e2types.InitBLS())
base, err := ioutil.TempDir("", "")
base, err := os.MkdirTemp("", "")
require.NoError(t, err)
defer os.RemoveAll(base)
store := filesystem.New(filesystem.WithLocation(base))

View File

@@ -15,7 +15,6 @@ package walletexport
import (
"context"
"io/ioutil"
"os"
"testing"
"time"
@@ -31,7 +30,7 @@ import (
func TestProcess(t *testing.T) {
require.NoError(t, e2types.InitBLS())
base, err := ioutil.TempDir("", "")
base, err := os.MkdirTemp("", "")
require.NoError(t, err)
defer os.RemoveAll(base)
store := filesystem.New(filesystem.WithLocation(base))

View File

@@ -16,7 +16,7 @@ package walletimport
import (
"context"
"encoding/hex"
"io/ioutil"
"os"
"strings"
"time"
@@ -58,7 +58,7 @@ func input(ctx context.Context) (*dataIn, error) {
}
if !strings.HasPrefix(viper.GetString("data"), "0x") {
// Assume this is a path; read the file and replace the path with its contents.
fileData, err := ioutil.ReadFile(viper.GetString("data"))
fileData, err := os.ReadFile(viper.GetString("data"))
if err != nil {
return nil, errors.Wrap(err, "failed to read wallet import data")
}

View File

@@ -1,4 +1,4 @@
// Copyright © 2021 Weald Technology Trading
// Copyright © 2021, 2022 Weald Technology Trading
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@@ -15,7 +15,6 @@ package walletsharedexport
import (
"context"
"io/ioutil"
"os"
"testing"
"time"
@@ -31,7 +30,7 @@ import (
func TestProcess(t *testing.T) {
require.NoError(t, e2types.InitBLS())
base, err := ioutil.TempDir("", "")
base, err := os.MkdirTemp("", "")
require.NoError(t, err)
defer os.RemoveAll(base)
store := filesystem.New(filesystem.WithLocation(base))

View File

@@ -1,4 +1,4 @@
// Copyright © 2021 Weald Technology Trading
// Copyright © 2021, 2022 Weald Technology Trading
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@@ -15,7 +15,7 @@ package walletsharedimport
import (
"context"
"io/ioutil"
"os"
"time"
"github.com/pkg/errors"
@@ -52,7 +52,7 @@ func input(ctx context.Context) (*dataIn, error) {
if viper.GetString("file") == "" {
return nil, errors.New("file is required")
}
data.file, err = ioutil.ReadFile(viper.GetString("file"))
data.file, err = os.ReadFile(viper.GetString("file"))
if err != nil {
return nil, errors.Wrap(err, "failed to read wallet import file")
}

View File

@@ -1,4 +1,4 @@
// Copyright © 2021 Weald Technology Trading
// Copyright © 2021, 2022 Weald Technology Trading
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@@ -16,7 +16,6 @@ package walletsharedimport
import (
"context"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"testing"
@@ -38,7 +37,7 @@ func TestInput(t *testing.T) {
dir, err := os.MkdirTemp("", "")
require.NoError(t, err)
datFile := filepath.Join(dir, "backup.dat")
require.NoError(t, ioutil.WriteFile(datFile, []byte("dummy"), 0600))
require.NoError(t, os.WriteFile(datFile, []byte("dummy"), 0600))
defer os.RemoveAll(dir)
store := scratch.New()

View File

@@ -1,4 +1,4 @@
// Copyright © 2021 Weald Technology Trading
// Copyright © 2021, 2022 Weald Technology Trading
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
@@ -15,7 +15,6 @@ package walletsharedimport
import (
"context"
"io/ioutil"
"os"
"path/filepath"
"testing"
@@ -40,7 +39,7 @@ func TestProcess(t *testing.T) {
dir, err := os.MkdirTemp("", "")
require.NoError(t, err)
datFile := filepath.Join(dir, "backup.dat")
require.NoError(t, ioutil.WriteFile(datFile, export, 0600))
require.NoError(t, os.WriteFile(datFile, export, 0600))
defer os.RemoveAll(dir)
tests := []struct {