forked from TrueCloudLab/frostfs-node
[#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:
parent
3bdab77c42
commit
622ea4818f
9 changed files with 28 additions and 32 deletions
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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 })
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math/big"
|
||||
"math/rand"
|
||||
"net"
|
||||
|
@ -200,7 +199,7 @@ func storageConfig(cmd *cobra.Command, args []string) {
|
|||
}
|
||||
|
||||
out := applyTemplate(c)
|
||||
fatalOnErr(ioutil.WriteFile(outPath, out, 0644))
|
||||
fatalOnErr(os.WriteFile(outPath, out, 0644))
|
||||
|
||||
cmd.Println("Node is ready for work! Run `neofs-node -config " + outPath + "`")
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
|
@ -123,7 +122,7 @@ func createEACL(cmd *cobra.Command, _ []string) {
|
|||
return
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(outArg, buf.Bytes(), 0644)
|
||||
err = os.WriteFile(outArg, buf.Bytes(), 0644)
|
||||
if err != nil {
|
||||
cmd.PrintErrln(err)
|
||||
os.Exit(1)
|
||||
|
@ -135,7 +134,7 @@ func getRulesFromFile(filename string) ([]string, error) {
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
data, err := ioutil.ReadFile(filename)
|
||||
data, err := os.ReadFile(filename)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package cmd
|
|||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
@ -39,7 +39,7 @@ func Test_getKey(t *testing.T) {
|
|||
keyPath := filepath.Join(dir, "binary.key")
|
||||
rawKey, err := keys.NewPrivateKey()
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, ioutil.WriteFile(keyPath, rawKey.Bytes(), os.ModePerm))
|
||||
require.NoError(t, os.WriteFile(keyPath, rawKey.Bytes(), os.ModePerm))
|
||||
|
||||
wifKey, err := keys.NewPrivateKey()
|
||||
require.NoError(t, err)
|
||||
|
@ -52,7 +52,7 @@ func Test_getKey(t *testing.T) {
|
|||
in := bytes.NewBuffer(nil)
|
||||
input.Terminal = term.NewTerminal(input.ReadWriter{
|
||||
Reader: in,
|
||||
Writer: ioutil.Discard,
|
||||
Writer: io.Discard,
|
||||
}, "")
|
||||
|
||||
checkKeyError(t, filepath.Join(dir, "badfile"), errInvalidKey)
|
||||
|
|
|
@ -2,7 +2,7 @@ package inspect
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
common "github.com/nspcc-dev/neofs-node/cmd/neofs-lens/internal"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobovnicza"
|
||||
|
@ -111,7 +111,7 @@ func printObjectInfo(cmd *cobra.Command, data []byte) {
|
|||
}
|
||||
|
||||
if vOut != "" {
|
||||
err := ioutil.WriteFile(vOut, obj.Payload(), 0644)
|
||||
err := os.WriteFile(vOut, obj.Payload(), 0644)
|
||||
common.ExitOnErr(cmd, common.Errf("couldn't write payload: %w", err))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue