[#1250] *: Remove io/ioutil imports

It is deprecated starting from go1.16.

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-03-18 14:12:58 +03:00 committed by Alex Vanin
parent 3bdab77c42
commit 622ea4818f
9 changed files with 28 additions and 32 deletions

View file

@ -4,7 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
"sort"
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
@ -112,7 +112,7 @@ func dumpContainers(cmd *cobra.Command, _ []string) error {
if err != nil {
return err
}
return ioutil.WriteFile(filename, out, 0o660)
return os.WriteFile(filename, out, 0o660)
}
func restoreContainers(cmd *cobra.Command, _ []string) error {
@ -136,7 +136,7 @@ func restoreContainers(cmd *cobra.Command, _ []string) error {
return fmt.Errorf("can't fetch container contract hash: %w", err)
}
data, err := ioutil.ReadFile(filename)
data, err := os.ReadFile(filename)
if err != nil {
return fmt.Errorf("can't read dump file: %w", err)
}

View file

@ -2,7 +2,7 @@ package morph
import (
"bytes"
"io/ioutil"
"io"
"math/rand"
"os"
"path/filepath"
@ -101,7 +101,7 @@ func setupTestTerminal(t *testing.T) *bytes.Buffer {
in := bytes.NewBuffer(nil)
input.Terminal = term.NewTerminal(input.ReadWriter{
Reader: in,
Writer: ioutil.Discard,
Writer: io.Discard,
}, "")
t.Cleanup(func() { input.Terminal = nil })

View file

@ -3,7 +3,7 @@ package morph
import (
"errors"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"time"
@ -186,7 +186,7 @@ func (c *initializeContext) nativeHash(name string) util.Uint160 {
}
func openAlphabetWallets(walletDir string) ([]*wallet.Wallet, error) {
walletFiles, err := ioutil.ReadDir(walletDir)
walletFiles, err := os.ReadDir(walletDir)
if err != nil {
return nil, fmt.Errorf("can't read alphabet wallets dir: %w", err)
}

View file

@ -8,7 +8,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
@ -392,11 +391,11 @@ func (c *initializeContext) readContracts(names []string) error {
if c.ContractPath != "" && fi.IsDir() {
for _, ctrName := range names {
cs := new(contractState)
cs.RawNEF, err = ioutil.ReadFile(filepath.Join(c.ContractPath, ctrName, ctrName+"_contract.nef"))
cs.RawNEF, err = os.ReadFile(filepath.Join(c.ContractPath, ctrName, ctrName+"_contract.nef"))
if err != nil {
return fmt.Errorf("can't read NEF file for %s contract: %w", ctrName, err)
}
cs.RawManifest, err = ioutil.ReadFile(filepath.Join(c.ContractPath, ctrName, "config.json"))
cs.RawManifest, err = os.ReadFile(filepath.Join(c.ContractPath, ctrName, "config.json"))
if err != nil {
return fmt.Errorf("can't read manifest file for %s contract: %w", ctrName, err)
}
@ -481,12 +480,12 @@ func readContractsFromArchive(file io.Reader, names []string) (map[string]*contr
switch {
case strings.HasSuffix(h.Name, filepath.Join(ctrName, ctrName+"_contract.nef")):
cs.RawNEF, err = ioutil.ReadAll(r)
cs.RawNEF, err = io.ReadAll(r)
if err != nil {
return nil, fmt.Errorf("can't read NEF file for %s contract: %w", ctrName, err)
}
case strings.HasSuffix(h.Name, "config.json"):
cs.RawManifest, err = ioutil.ReadAll(r)
cs.RawManifest, err = io.ReadAll(r)
if err != nil {
return nil, fmt.Errorf("can't read manifest file for %s contract: %w", ctrName, err)
}