all: replace uses of ioutil with io and os (#24869)

This commit is contained in:
Håvard Anda Estensen
2022-05-16 11:59:35 +02:00
committed by GitHub
parent 330e53fbb9
commit 07508ac0e9
97 changed files with 203 additions and 257 deletions
+6 -6
View File
@@ -19,7 +19,7 @@ package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"os"
"path/filepath"
"regexp"
@@ -155,9 +155,9 @@ func abigen(c *cli.Context) error {
)
input := c.GlobalString(abiFlag.Name)
if input == "-" {
abi, err = ioutil.ReadAll(os.Stdin)
abi, err = io.ReadAll(os.Stdin)
} else {
abi, err = ioutil.ReadFile(input)
abi, err = os.ReadFile(input)
}
if err != nil {
utils.Fatalf("Failed to read input ABI: %v", err)
@@ -166,7 +166,7 @@ func abigen(c *cli.Context) error {
var bin []byte
if binFile := c.GlobalString(binFlag.Name); binFile != "" {
if bin, err = ioutil.ReadFile(binFile); err != nil {
if bin, err = os.ReadFile(binFile); err != nil {
utils.Fatalf("Failed to read input bytecode: %v", err)
}
if strings.Contains(string(bin), "//") {
@@ -213,7 +213,7 @@ func abigen(c *cli.Context) error {
}
case c.GlobalIsSet(jsonFlag.Name):
jsonOutput, err := ioutil.ReadFile(c.GlobalString(jsonFlag.Name))
jsonOutput, err := os.ReadFile(c.GlobalString(jsonFlag.Name))
if err != nil {
utils.Fatalf("Failed to read combined-json from compiler: %v", err)
}
@@ -263,7 +263,7 @@ func abigen(c *cli.Context) error {
fmt.Printf("%s\n", code)
return nil
}
if err := ioutil.WriteFile(c.GlobalString(outFlag.Name), []byte(code), 0600); err != nil {
if err := os.WriteFile(c.GlobalString(outFlag.Name), []byte(code), 0600); err != nil {
utils.Fatalf("Failed to write ABI binding: %v", err)
}
return nil
+3 -4
View File
@@ -25,7 +25,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"math/big"
"os"
"os/signal"
@@ -374,7 +373,7 @@ func initializeSecrets(c *cli.Context) error {
return fmt.Errorf("master key %v already exists, will not overwrite", location)
}
// Write the file and print the usual warning message
if err = ioutil.WriteFile(location, cipherSeed, 0400); err != nil {
if err = os.WriteFile(location, cipherSeed, 0400); err != nil {
return err
}
fmt.Printf("A master seed has been generated into %s\n", location)
@@ -593,7 +592,7 @@ func signer(c *cli.Context) error {
// Do we have a rule-file?
if ruleFile := c.GlobalString(ruleFlag.Name); ruleFile != "" {
ruleJS, err := ioutil.ReadFile(ruleFile)
ruleJS, err := os.ReadFile(ruleFile)
if err != nil {
log.Warn("Could not load rules, disabling", "file", ruleFile, "err", err)
} else {
@@ -751,7 +750,7 @@ func readMasterKey(ctx *cli.Context, ui core.UIClientAPI) ([]byte, error) {
if err := checkFile(file); err != nil {
return nil, err
}
cipherKey, err := ioutil.ReadFile(file)
cipherKey, err := os.ReadFile(file)
if err != nil {
return nil, err
}
+3 -4
View File
@@ -20,7 +20,6 @@ import (
"crypto/ecdsa"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"time"
@@ -253,7 +252,7 @@ func dnsNukeRoute53(ctx *cli.Context) error {
// loadSigningKey loads a private key in Ethereum keystore format.
func loadSigningKey(keyfile string) *ecdsa.PrivateKey {
keyjson, err := ioutil.ReadFile(keyfile)
keyjson, err := os.ReadFile(keyfile)
if err != nil {
exit(fmt.Errorf("failed to read the keyfile at '%s': %v", keyfile, err))
}
@@ -382,7 +381,7 @@ func writeTreeMetadata(directory string, def *dnsDefinition) {
exit(err)
}
metaFile, _ := treeDefinitionFiles(directory)
if err := ioutil.WriteFile(metaFile, metaJSON, 0644); err != nil {
if err := os.WriteFile(metaFile, metaJSON, 0644); err != nil {
exit(err)
}
}
@@ -411,7 +410,7 @@ func writeTXTJSON(file string, txt map[string]string) {
fmt.Println()
return
}
if err := ioutil.WriteFile(file, txtJSON, 0644); err != nil {
if err := os.WriteFile(file, txtJSON, 0644); err != nil {
exit(err)
}
}
+2 -3
View File
@@ -22,7 +22,6 @@ import (
"encoding/hex"
"fmt"
"io"
"io/ioutil"
"net"
"os"
"strconv"
@@ -54,9 +53,9 @@ func enrdump(ctx *cli.Context) error {
var b []byte
var err error
if file == "-" {
b, err = ioutil.ReadAll(os.Stdin)
b, err = io.ReadAll(os.Stdin)
} else {
b, err = ioutil.ReadFile(file)
b, err = os.ReadFile(file)
}
if err != nil {
return err
+1 -2
View File
@@ -21,7 +21,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"math/big"
"os"
"strings"
@@ -153,7 +152,7 @@ func loadChain(chainfile string, genesis string) (*Chain, error) {
}
func loadGenesis(genesisFile string) (core.Genesis, error) {
chainConfig, err := ioutil.ReadFile(genesisFile)
chainConfig, err := os.ReadFile(genesisFile)
if err != nil {
return core.Genesis{}, err
}
+1 -2
View File
@@ -20,7 +20,6 @@ import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"sort"
"time"
@@ -66,7 +65,7 @@ func writeNodesJSON(file string, nodes nodeSet) {
os.Stdout.Write(nodesJSON)
return
}
if err := ioutil.WriteFile(file, nodesJSON, 0644); err != nil {
if err := os.WriteFile(file, nodesJSON, 0644); err != nil {
exit(err)
}
}
+4 -4
View File
@@ -18,7 +18,7 @@ package main
import (
"fmt"
"io/ioutil"
"os"
"strings"
"github.com/ethereum/go-ethereum/accounts/keystore"
@@ -45,7 +45,7 @@ Change the password of a keyfile.`,
keyfilepath := ctx.Args().First()
// Read key from file.
keyjson, err := ioutil.ReadFile(keyfilepath)
keyjson, err := os.ReadFile(keyfilepath)
if err != nil {
utils.Fatalf("Failed to read the keyfile at '%s': %v", keyfilepath, err)
}
@@ -61,7 +61,7 @@ Change the password of a keyfile.`,
fmt.Println("Please provide a new password")
var newPhrase string
if passFile := ctx.String(newPassphraseFlag.Name); passFile != "" {
content, err := ioutil.ReadFile(passFile)
content, err := os.ReadFile(passFile)
if err != nil {
utils.Fatalf("Failed to read new password file '%s': %v", passFile, err)
}
@@ -77,7 +77,7 @@ Change the password of a keyfile.`,
}
// Then write the new keyfile in place of the old one.
if err := ioutil.WriteFile(keyfilepath, newJson, 0600); err != nil {
if err := os.WriteFile(keyfilepath, newJson, 0600); err != nil {
utils.Fatalf("Error writing new keyfile to disk: %v", err)
}
+1 -2
View File
@@ -19,7 +19,6 @@ package main
import (
"crypto/ecdsa"
"fmt"
"io/ioutil"
"os"
"path/filepath"
@@ -116,7 +115,7 @@ If you want to encrypt an existing private key, it can be specified by setting
if err := os.MkdirAll(filepath.Dir(keyfilepath), 0700); err != nil {
utils.Fatalf("Could not create directory %s", filepath.Dir(keyfilepath))
}
if err := ioutil.WriteFile(keyfilepath, keyjson, 0600); err != nil {
if err := os.WriteFile(keyfilepath, keyjson, 0600); err != nil {
utils.Fatalf("Failed to write keyfile to %s: %v", keyfilepath, err)
}
+2 -2
View File
@@ -19,7 +19,7 @@ package main
import (
"encoding/hex"
"fmt"
"io/ioutil"
"os"
"github.com/ethereum/go-ethereum/accounts/keystore"
"github.com/ethereum/go-ethereum/cmd/utils"
@@ -58,7 +58,7 @@ make sure to use this feature with great caution!`,
keyfilepath := ctx.Args().First()
// Read key from file.
keyjson, err := ioutil.ReadFile(keyfilepath)
keyjson, err := os.ReadFile(keyfilepath)
if err != nil {
utils.Fatalf("Failed to read the keyfile at '%s': %v", keyfilepath, err)
}
+3 -3
View File
@@ -19,7 +19,7 @@ package main
import (
"encoding/hex"
"fmt"
"io/ioutil"
"os"
"github.com/ethereum/go-ethereum/accounts/keystore"
"github.com/ethereum/go-ethereum/cmd/utils"
@@ -56,7 +56,7 @@ To sign a message contained in a file, use the --msgfile flag.
// Load the keyfile.
keyfilepath := ctx.Args().First()
keyjson, err := ioutil.ReadFile(keyfilepath)
keyjson, err := os.ReadFile(keyfilepath)
if err != nil {
utils.Fatalf("Failed to read the keyfile at '%s': %v", keyfilepath, err)
}
@@ -146,7 +146,7 @@ func getMessage(ctx *cli.Context, msgarg int) []byte {
if len(ctx.Args()) > msgarg {
utils.Fatalf("Can't use --msgfile and message argument at the same time.")
}
msg, err := ioutil.ReadFile(file)
msg, err := os.ReadFile(file)
if err != nil {
utils.Fatalf("Can't read message file: %v", err)
}
+2 -2
View File
@@ -19,7 +19,7 @@ package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"strings"
"github.com/ethereum/go-ethereum/cmd/utils"
@@ -34,7 +34,7 @@ func getPassphrase(ctx *cli.Context, confirmation bool) string {
// Look for the --passwordfile flag.
passphraseFile := ctx.String(passphraseFlag.Name)
if passphraseFile != "" {
content, err := ioutil.ReadFile(passphraseFile)
content, err := os.ReadFile(passphraseFile)
if err != nil {
utils.Fatalf("Failed to read password file '%s': %v",
passphraseFile, err)
+2 -2
View File
@@ -19,7 +19,7 @@ package main
import (
"errors"
"fmt"
"io/ioutil"
"os"
"github.com/ethereum/go-ethereum/cmd/evm/internal/compiler"
@@ -41,7 +41,7 @@ func compileCmd(ctx *cli.Context) error {
}
fn := ctx.Args().First()
src, err := ioutil.ReadFile(fn)
src, err := os.ReadFile(fn)
if err != nil {
return err
}
+2 -2
View File
@@ -19,7 +19,7 @@ package main
import (
"errors"
"fmt"
"io/ioutil"
"os"
"strings"
"github.com/ethereum/go-ethereum/core/asm"
@@ -38,7 +38,7 @@ func disasmCmd(ctx *cli.Context) error {
switch {
case len(ctx.Args().First()) > 0:
fn := ctx.Args().First()
input, err := ioutil.ReadFile(fn)
input, err := os.ReadFile(fn)
if err != nil {
return err
}
+1 -2
View File
@@ -21,7 +21,6 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"math/big"
"os"
"path"
@@ -401,7 +400,7 @@ func saveFile(baseDir, filename string, data interface{}) error {
return NewError(ErrorJson, fmt.Errorf("failed marshalling output: %v", err))
}
location := path.Join(baseDir, filename)
if err = ioutil.WriteFile(location, b, 0644); err != nil {
if err = os.WriteFile(location, b, 0644); err != nil {
return NewError(ErrorIO, fmt.Errorf("failed writing output: %v", err))
}
log.Info("Wrote file", "file", location)
+5 -5
View File
@@ -20,7 +20,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"math/big"
"os"
goruntime "runtime"
@@ -165,13 +165,13 @@ func runCmd(ctx *cli.Context) error {
// If - is specified, it means that code comes from stdin
if codeFileFlag == "-" {
//Try reading from stdin
if hexcode, err = ioutil.ReadAll(os.Stdin); err != nil {
if hexcode, err = io.ReadAll(os.Stdin); err != nil {
fmt.Printf("Could not load code from stdin: %v\n", err)
os.Exit(1)
}
} else {
// Codefile with hex assembly
if hexcode, err = ioutil.ReadFile(codeFileFlag); err != nil {
if hexcode, err = os.ReadFile(codeFileFlag); err != nil {
fmt.Printf("Could not load code from file: %v\n", err)
os.Exit(1)
}
@@ -187,7 +187,7 @@ func runCmd(ctx *cli.Context) error {
code = common.FromHex(string(hexcode))
} else if fn := ctx.Args().First(); len(fn) > 0 {
// EASM-file to compile
src, err := ioutil.ReadFile(fn)
src, err := os.ReadFile(fn)
if err != nil {
return err
}
@@ -239,7 +239,7 @@ func runCmd(ctx *cli.Context) error {
var hexInput []byte
if inputFileFlag := ctx.GlobalString(InputFileFlag.Name); inputFileFlag != "" {
var err error
if hexInput, err = ioutil.ReadFile(inputFileFlag); err != nil {
if hexInput, err = os.ReadFile(inputFileFlag); err != nil {
fmt.Printf("could not load input from file: %v\n", err)
os.Exit(1)
}
+1 -2
View File
@@ -20,7 +20,6 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
"github.com/ethereum/go-ethereum/core/state"
@@ -81,7 +80,7 @@ func stateTestCmd(ctx *cli.Context) error {
debugger = logger.NewStructLogger(config)
}
// Load the test content from the input file
src, err := ioutil.ReadFile(ctx.Args().First())
src, err := os.ReadFile(ctx.Args().First())
if err != nil {
return err
}
+5 -5
View File
@@ -26,7 +26,7 @@ import (
"flag"
"fmt"
"html/template"
"io/ioutil"
"io"
"math"
"math/big"
"net/http"
@@ -157,14 +157,14 @@ func main() {
}
}
// Load up the account key and decrypt its password
blob, err := ioutil.ReadFile(*accPassFlag)
blob, err := os.ReadFile(*accPassFlag)
if err != nil {
log.Crit("Failed to read account password contents", "file", *accPassFlag, "err", err)
}
pass := strings.TrimSuffix(string(blob), "\n")
ks := keystore.NewKeyStore(filepath.Join(os.Getenv("HOME"), ".faucet", "keys"), keystore.StandardScryptN, keystore.StandardScryptP)
if blob, err = ioutil.ReadFile(*accJSONFlag); err != nil {
if blob, err = os.ReadFile(*accJSONFlag); err != nil {
log.Crit("Failed to read account key contents", "file", *accJSONFlag, "err", err)
}
acc, err := ks.Import(blob, pass, pass)
@@ -727,7 +727,7 @@ func authTwitter(url string, tokenV1, tokenV2 string) (string, string, string, c
}
username := parts[len(parts)-3]
body, err := ioutil.ReadAll(res.Body)
body, err := io.ReadAll(res.Body)
if err != nil {
return "", "", "", common.Address{}, err
}
@@ -853,7 +853,7 @@ func authFacebook(url string) (string, string, common.Address, error) {
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
body, err := io.ReadAll(res.Body)
if err != nil {
return "", "", common.Address{}, err
}
+2 -2
View File
@@ -18,7 +18,7 @@ package main
import (
"fmt"
"io/ioutil"
"os"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts/keystore"
@@ -320,7 +320,7 @@ func importWallet(ctx *cli.Context) error {
if len(keyfile) == 0 {
utils.Fatalf("keyfile must be given as argument")
}
keyJSON, err := ioutil.ReadFile(keyfile)
keyJSON, err := os.ReadFile(keyfile)
if err != nil {
utils.Fatalf("Could not read wallet file: %v", err)
}
+3 -2
View File
@@ -18,6 +18,7 @@ package main
import (
"io/ioutil"
"os"
"path/filepath"
"runtime"
"strings"
@@ -113,11 +114,11 @@ func TestAccountImport(t *testing.T) {
func importAccountWithExpect(t *testing.T, key string, expected string) {
dir := t.TempDir()
keyfile := filepath.Join(dir, "key.prv")
if err := ioutil.WriteFile(keyfile, []byte(key), 0600); err != nil {
if err := os.WriteFile(keyfile, []byte(key), 0600); err != nil {
t.Error(err)
}
passwordFile := filepath.Join(dir, "password.txt")
if err := ioutil.WriteFile(passwordFile, []byte("foobar"), 0600); err != nil {
if err := os.WriteFile(passwordFile, []byte("foobar"), 0600); err != nil {
t.Error(err)
}
geth := runGeth(t, "--lightkdf", "account", "import", keyfile, "-password", passwordFile)
+2 -2
View File
@@ -17,8 +17,8 @@
package main
import (
"io/ioutil"
"math/big"
"os"
"path/filepath"
"testing"
@@ -110,7 +110,7 @@ func testDAOForkBlockNewChain(t *testing.T, test int, genesis string, expectBloc
// Start a Geth instance with the requested flags set and immediately terminate
if genesis != "" {
json := filepath.Join(datadir, "genesis.json")
if err := ioutil.WriteFile(json, []byte(genesis), 0600); err != nil {
if err := os.WriteFile(json, []byte(genesis), 0600); err != nil {
t.Fatalf("test %d: failed to write genesis file: %v", test, err)
}
runGeth(t, "--datadir", datadir, "--networkid", "1337", "init", json).WaitExit()
+2 -2
View File
@@ -17,7 +17,7 @@
package main
import (
"io/ioutil"
"os"
"path/filepath"
"testing"
)
@@ -76,7 +76,7 @@ func TestCustomGenesis(t *testing.T) {
// Initialize the data directory with the custom genesis block
json := filepath.Join(datadir, "genesis.json")
if err := ioutil.WriteFile(json, []byte(tt.genesis), 0600); err != nil {
if err := os.WriteFile(json, []byte(tt.genesis), 0600); err != nil {
t.Fatalf("test %d: failed to write genesis file: %v", i, err)
}
runGeth(t, "--datadir", datadir, "init", json).WaitExit()
+4 -3
View File
@@ -20,8 +20,9 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"net/http"
"os"
"regexp"
"strings"
@@ -112,14 +113,14 @@ func checkCurrent(url, current string) error {
// fetch makes an HTTP request to the given url and returns the response body
func fetch(url string) ([]byte, error) {
if filep := strings.TrimPrefix(url, "file://"); filep != url {
return ioutil.ReadFile(filep)
return os.ReadFile(filep)
}
res, err := http.Get(url)
if err != nil {
return nil, err
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
body, err := io.ReadAll(res.Body)
if err != nil {
return nil, err
}
+4 -3
View File
@@ -20,6 +20,7 @@ import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"regexp"
"strconv"
@@ -49,7 +50,7 @@ func TestVerification(t *testing.T) {
func testVerification(t *testing.T, pubkey, sigdir string) {
// Data to verify
data, err := ioutil.ReadFile("./testdata/vcheck/data.json")
data, err := os.ReadFile("./testdata/vcheck/data.json")
if err != nil {
t.Fatal(err)
}
@@ -59,7 +60,7 @@ func testVerification(t *testing.T, pubkey, sigdir string) {
t.Fatal(err)
}
for _, f := range files {
sig, err := ioutil.ReadFile(filepath.Join(sigdir, f.Name()))
sig, err := os.ReadFile(filepath.Join(sigdir, f.Name()))
if err != nil {
t.Fatal(err)
}
@@ -87,7 +88,7 @@ func versionUint(v string) int {
// TestMatching can be used to check that the regexps are correct
func TestMatching(t *testing.T) {
data, _ := ioutil.ReadFile("./testdata/vcheck/vulnerabilities.json")
data, _ := os.ReadFile("./testdata/vcheck/vulnerabilities.json")
var vulns []vulnJson
if err := json.Unmarshal(data, &vulns); err != nil {
t.Fatal(err)
+5 -5
View File
@@ -19,7 +19,7 @@ package main
import (
"bytes"
"encoding/json"
"io/ioutil"
"os"
"reflect"
"strings"
"testing"
@@ -30,7 +30,7 @@ import (
// Tests the go-ethereum to Aleth chainspec conversion for the Stureby testnet.
func TestAlethSturebyConverter(t *testing.T) {
blob, err := ioutil.ReadFile("testdata/stureby_geth.json")
blob, err := os.ReadFile("testdata/stureby_geth.json")
if err != nil {
t.Fatalf("could not read file: %v", err)
}
@@ -43,7 +43,7 @@ func TestAlethSturebyConverter(t *testing.T) {
t.Fatalf("failed creating chainspec: %v", err)
}
expBlob, err := ioutil.ReadFile("testdata/stureby_aleth.json")
expBlob, err := os.ReadFile("testdata/stureby_aleth.json")
if err != nil {
t.Fatalf("could not read file: %v", err)
}
@@ -69,7 +69,7 @@ func TestAlethSturebyConverter(t *testing.T) {
// Tests the go-ethereum to Parity chainspec conversion for the Stureby testnet.
func TestParitySturebyConverter(t *testing.T) {
blob, err := ioutil.ReadFile("testdata/stureby_geth.json")
blob, err := os.ReadFile("testdata/stureby_geth.json")
if err != nil {
t.Fatalf("could not read file: %v", err)
}
@@ -85,7 +85,7 @@ func TestParitySturebyConverter(t *testing.T) {
if err != nil {
t.Fatalf("failed encoding chainspec: %v", err)
}
expBlob, err := ioutil.ReadFile("testdata/stureby_parity.json")
expBlob, err := os.ReadFile("testdata/stureby_parity.json")
if err != nil {
t.Fatalf("could not read file: %v", err)
}
+1 -2
View File
@@ -21,7 +21,6 @@ import (
"bytes"
"errors"
"fmt"
"io/ioutil"
"net"
"os"
"os/user"
@@ -96,7 +95,7 @@ func dial(server string, pubkey []byte) (*sshClient, error) {
}
if err != nil {
path := filepath.Join(user.HomeDir, ".ssh", identity)
if buf, err := ioutil.ReadFile(path); err != nil {
if buf, err := os.ReadFile(path); err != nil {
log.Warn("No SSH key, falling back to passwords", "path", path, "err", err)
} else {
key, err := ssh.ParsePrivateKey(buf)
+1 -2
View File
@@ -19,7 +19,6 @@ package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"math/big"
"net"
"net/url"
@@ -65,7 +64,7 @@ func (c config) flush() {
os.MkdirAll(filepath.Dir(c.path), 0755)
out, _ := json.MarshalIndent(c, "", " ")
if err := ioutil.WriteFile(c.path, out, 0644); err != nil {
if err := os.WriteFile(c.path, out, 0644); err != nil {
log.Warn("Failed to save puppeth configs", "file", c.path, "err", err)
}
}
+2 -3
View File
@@ -21,7 +21,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"math/big"
"math/rand"
"net/http"
@@ -263,7 +262,7 @@ func (w *wizard) manageGenesis() {
// Export the native genesis spec used by puppeth and Geth
gethJson := filepath.Join(folder, fmt.Sprintf("%s.json", w.network))
if err := ioutil.WriteFile(gethJson, out, 0644); err != nil {
if err := os.WriteFile(gethJson, out, 0644); err != nil {
log.Error("Failed to save genesis file", "err", err)
return
}
@@ -305,7 +304,7 @@ func saveGenesis(folder, network, client string, spec interface{}) {
path := filepath.Join(folder, fmt.Sprintf("%s-%s.json", network, client))
out, _ := json.MarshalIndent(spec, "", " ")
if err := ioutil.WriteFile(path, out, 0644); err != nil {
if err := os.WriteFile(path, out, 0644); err != nil {
log.Error("Failed to save genesis file", "client", client, "err", err)
return
}
+1 -2
View File
@@ -19,7 +19,6 @@ package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
@@ -73,7 +72,7 @@ func (w *wizard) run() {
// Load initial configurations and connect to all live servers
w.conf.path = filepath.Join(os.Getenv("HOME"), ".puppeth", w.network)
blob, err := ioutil.ReadFile(w.conf.path)
blob, err := os.ReadFile(w.conf.path)
if err != nil {
log.Warn("No previous configurations found", "path", w.conf.path)
} else if err := json.Unmarshal(blob, &w.conf); err != nil {
+1 -2
View File
@@ -21,7 +21,6 @@ import (
"crypto/ecdsa"
"fmt"
"io"
"io/ioutil"
"math"
"math/big"
"os"
@@ -1213,7 +1212,7 @@ func MakePasswordList(ctx *cli.Context) []string {
if path == "" {
return nil
}
text, err := ioutil.ReadFile(path)
text, err := os.ReadFile(path)
if err != nil {
Fatalf("Failed to read password file: %v", err)
}