multi: repleace ioutil.ReadAll

This commit is contained in:
erik
2023-06-13 20:17:03 +07:00
committed by ErikEk
parent 8ce3622792
commit 619c8f4eb8
8 changed files with 12 additions and 16 deletions

View File

@@ -5,7 +5,7 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io"
"net" "net"
"net/url" "net/url"
"os" "os"
@@ -547,7 +547,7 @@ func NewPartialChainControl(cfg *Config) (*PartialChainControl, func(), error) {
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
rpcCert, err = ioutil.ReadAll(certFile) rpcCert, err = io.ReadAll(certFile)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }

View File

@@ -2,7 +2,6 @@ package lnwire
import ( import (
"io" "io"
"io/ioutil"
) )
// AnnounceSignatures is a direct message between two endpoints of a // AnnounceSignatures is a direct message between two endpoints of a
@@ -66,7 +65,7 @@ func (a *AnnounceSignatures) Decode(r io.Reader, pver uint32) error {
// we'll collect the remainder into the ExtraOpaqueData field. If there // we'll collect the remainder into the ExtraOpaqueData field. If there
// aren't any bytes, then we'll snip off the slice to avoid carrying // aren't any bytes, then we'll snip off the slice to avoid carrying
// around excess capacity. // around excess capacity.
a.ExtraOpaqueData, err = ioutil.ReadAll(r) a.ExtraOpaqueData, err = io.ReadAll(r)
if err != nil { if err != nil {
return err return err
} }

View File

@@ -3,7 +3,6 @@ package lnwire
import ( import (
"bytes" "bytes"
"io" "io"
"io/ioutil"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
) )
@@ -89,7 +88,7 @@ func (a *ChannelAnnouncement) Decode(r io.Reader, pver uint32) error {
// we'll collect the remainder into the ExtraOpaqueData field. If there // we'll collect the remainder into the ExtraOpaqueData field. If there
// aren't any bytes, then we'll snip off the slice to avoid carrying // aren't any bytes, then we'll snip off the slice to avoid carrying
// around excess capacity. // around excess capacity.
a.ExtraOpaqueData, err = ioutil.ReadAll(r) a.ExtraOpaqueData, err = io.ReadAll(r)
if err != nil { if err != nil {
return err return err
} }

View File

@@ -4,7 +4,6 @@ import (
"bytes" "bytes"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/chaincfg/chainhash"
) )
@@ -160,7 +159,7 @@ func (a *ChannelUpdate) Decode(r io.Reader, pver uint32) error {
// we'll collect the remainder into the ExtraOpaqueData field. If there // we'll collect the remainder into the ExtraOpaqueData field. If there
// aren't any bytes, then we'll snip off the slice to avoid carrying // aren't any bytes, then we'll snip off the slice to avoid carrying
// around excess capacity. // around excess capacity.
a.ExtraOpaqueData, err = ioutil.ReadAll(r) a.ExtraOpaqueData, err = io.ReadAll(r)
if err != nil { if err != nil {
return err return err
} }

View File

@@ -5,7 +5,6 @@ import (
"fmt" "fmt"
"image/color" "image/color"
"io" "io"
"io/ioutil"
"net" "net"
"unicode/utf8" "unicode/utf8"
) )
@@ -127,7 +126,7 @@ func (a *NodeAnnouncement) Decode(r io.Reader, pver uint32) error {
// we'll collect the remainder into the ExtraOpaqueData field. If there // we'll collect the remainder into the ExtraOpaqueData field. If there
// aren't any bytes, then we'll snip off the slice to avoid carrying // aren't any bytes, then we'll snip off the slice to avoid carrying
// around excess capacity. // around excess capacity.
a.ExtraOpaqueData, err = ioutil.ReadAll(r) a.ExtraOpaqueData, err = io.ReadAll(r)
if err != nil { if err != nil {
return err return err
} }

View File

@@ -7,7 +7,7 @@ import (
"encoding/hex" "encoding/hex"
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io"
"os" "os"
"runtime" "runtime"
"strconv" "strconv"
@@ -987,7 +987,7 @@ func sendToRoute(ctx *cli.Context) error {
// The user is signalling that we should read stdin in order to parse // The user is signalling that we should read stdin in order to parse
// the set of target routes. // the set of target routes.
case args.Present() && args.First() == "-": case args.Present() && args.First() == "-":
b, err := ioutil.ReadAll(os.Stdin) b, err := io.ReadAll(os.Stdin)
if err != nil { if err != nil {
return err return err
} }

View File

@@ -8,6 +8,7 @@ import (
"encoding/hex" "encoding/hex"
"errors" "errors"
"fmt" "fmt"
"io"
"io/ioutil" "io/ioutil"
"net" "net"
"os" "os"
@@ -2006,7 +2007,7 @@ func extractBtcdRPCParams(btcdConfigPath string) (string, string, error) {
// With the file open extract the contents of the configuration file so // With the file open extract the contents of the configuration file so
// we can attempt to locate the RPC credentials. // we can attempt to locate the RPC credentials.
configContents, err := ioutil.ReadAll(btcdConfigFile) configContents, err := io.ReadAll(btcdConfigFile)
if err != nil { if err != nil {
return "", "", err return "", "", err
} }
@@ -2056,7 +2057,7 @@ func extractBitcoindRPCParams(networkName, bitcoindDataDir, bitcoindConfigPath,
// With the file open extract the contents of the configuration file so // With the file open extract the contents of the configuration file so
// we can attempt to locate the RPC credentials. // we can attempt to locate the RPC credentials.
configContents, err := ioutil.ReadAll(bitcoindConfigFile) configContents, err := io.ReadAll(bitcoindConfigFile)
if err != nil { if err != nil {
return "", "", "", "", err return "", "", "", "", err
} }

View File

@@ -3,7 +3,6 @@ package contractcourt
import ( import (
"bytes" "bytes"
"io" "io"
"io/ioutil"
"testing" "testing"
sphinx "github.com/lightningnetwork/lightning-onion" sphinx "github.com/lightningnetwork/lightning-onion"
@@ -291,7 +290,7 @@ type mockOnionProcessor struct {
func (o *mockOnionProcessor) ReconstructHopIterator(r io.Reader, rHash []byte, func (o *mockOnionProcessor) ReconstructHopIterator(r io.Reader, rHash []byte,
_ hop.ReconstructBlindingInfo) (hop.Iterator, error) { _ hop.ReconstructBlindingInfo) (hop.Iterator, error) {
data, err := ioutil.ReadAll(r) data, err := io.ReadAll(r)
if err != nil { if err != nil {
return nil, err return nil, err
} }