Skip to content

Commit

Permalink
[dep] Remove deprecated calls to ioutil (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
georgezgeorgez authored Oct 10, 2023
1 parent 9eaedfa commit 33f4fac
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 18 deletions.
6 changes: 3 additions & 3 deletions app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package app
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"

"gopkg.in/urfave/cli.v1"
Expand Down Expand Up @@ -111,7 +111,7 @@ func applyFlagsToConfig(ctx *cli.Context, cfg *node.Config) {
}
func readConfigFromFile(ctx *cli.Context, cfg *node.Config) error {
if file := ctx.GlobalString(ConfigFileFlag.Name); file != "" {
if jsonConf, err := ioutil.ReadFile(file); err == nil {
if jsonConf, err := os.ReadFile(file); err == nil {
err = json.Unmarshal(jsonConf, &cfg)
if err == nil {
return nil
Expand All @@ -130,7 +130,7 @@ func readConfigFromFile(ctx *cli.Context, cfg *node.Config) error {

configPath := filepath.Join(dataPath, defaultNodeConfigFileName)

if jsonConf, err := ioutil.ReadFile(configPath); err == nil {
if jsonConf, err := os.ReadFile(configPath); err == nil {
err = json.Unmarshal(jsonConf, &cfg)
if err == nil {
return nil
Expand Down
3 changes: 1 addition & 2 deletions node/rpcstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
"sort"
Expand Down Expand Up @@ -422,7 +421,7 @@ func (h *virtualHostHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {

var gzPool = sync.Pool{
New: func() interface{} {
w := gzip.NewWriter(ioutil.Discard)
w := gzip.NewWriter(io.Discard)
return w
},
}
Expand Down
10 changes: 4 additions & 6 deletions p2p/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"net"
"sync"
"sync/atomic"
Expand Down Expand Up @@ -62,7 +61,7 @@ func (msg Msg) String() string {

// Discard reads any remaining payload data into a black hole.
func (msg Msg) Discard() error {
_, err := io.Copy(ioutil.Discard, msg.Payload)
_, err := io.Copy(io.Discard, msg.Payload)
return err
}

Expand Down Expand Up @@ -100,12 +99,11 @@ func Send(w MsgWriter, msgcode uint64, data interface{}) error {
// SendItems writes an RLP with the given code and data elements.
// For a call such as:
//
// SendItems(w, code, e1, e2, e3)
// SendItems(w, code, e1, e2, e3)
//
// the message payload will be an RLP list containing the items:
//
// [e1, e2, e3]
//
// [e1, e2, e3]
func SendItems(w MsgWriter, msgcode uint64, elems ...interface{}) error {
return Send(w, msgcode, elems)
}
Expand Down Expand Up @@ -261,7 +259,7 @@ func ExpectMsg(r MsgReader, code uint64, content interface{}) error {
if int(msg.Size) != len(contentEnc) {
return fmt.Errorf("message size mismatch: got %d, want %d", msg.Size, len(contentEnc))
}
actualContent, err := ioutil.ReadAll(msg.Payload)
actualContent, err := io.ReadAll(msg.Payload)
if err != nil {
return err
}
Expand Down
3 changes: 1 addition & 2 deletions rpc/server/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"mime"
"net/http"
"net/url"
Expand Down Expand Up @@ -169,7 +168,7 @@ func (hc *httpConn) doRequest(ctx context.Context, msg interface{}) (io.ReadClos
if err != nil {
return nil, err
}
req, err := http.NewRequestWithContext(ctx, "POST", hc.url, ioutil.NopCloser(bytes.NewReader(body)))
req, err := http.NewRequestWithContext(ctx, "POST", hc.url, io.NopCloser(bytes.NewReader(body)))
if err != nil {
return nil, err
}
Expand Down
3 changes: 1 addition & 2 deletions wallet/keyfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package wallet

import (
"encoding/json"
"io/ioutil"
"os"

"github.com/ethereum/go-ethereum/common/hexutil"
Expand Down Expand Up @@ -40,7 +39,7 @@ type argon2Params struct {
}

func ReadKeyFile(path string) (*KeyFile, error) {
keyFileJson, err := ioutil.ReadFile(path)
keyFileJson, err := os.ReadFile(path)
if err != nil {
return nil, err
}
Expand Down
5 changes: 2 additions & 3 deletions wallet/manager.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package wallet

import (
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -105,14 +104,14 @@ func (m *Manager) GetKeyFileAndDecrypt(path, password string) (*KeyStore, error)

// ListEntropyFilesInStandardDir reads them from the disk
func (m *Manager) ListEntropyFilesInStandardDir() ([]*KeyFile, error) {
filePaths, err := ioutil.ReadDir(m.config.WalletDir)
filePaths, err := os.ReadDir(m.config.WalletDir)
if err != nil {
return nil, err
}

files := make([]*KeyFile, 0)
for _, file := range filePaths {
if file.IsDir() || file.Mode()&os.ModeType != 0 {
if file.IsDir() || file.Type() != 0 {
continue
}
fn := file.Name()
Expand Down

0 comments on commit 33f4fac

Please sign in to comment.