From 619c8f4eb84eee8337909f9f112d49c997910693 Mon Sep 17 00:00:00 2001 From: erik Date: Tue, 13 Jun 2023 20:17:03 +0700 Subject: [PATCH] multi: repleace ioutil.ReadAll --- chainreg/chainregistry.go | 4 ++-- channeldb/migration/lnwire21/announcement_signatures.go | 3 +-- channeldb/migration/lnwire21/channel_announcement.go | 3 +-- channeldb/migration/lnwire21/channel_update.go | 3 +-- channeldb/migration/lnwire21/node_announcement.go | 3 +-- cmd/lncli/cmd_payments.go | 4 ++-- config.go | 5 +++-- contractcourt/htlc_incoming_contest_resolver_test.go | 3 +-- 8 files changed, 12 insertions(+), 16 deletions(-) diff --git a/chainreg/chainregistry.go b/chainreg/chainregistry.go index 036da71a5..8b562e87a 100644 --- a/chainreg/chainregistry.go +++ b/chainreg/chainregistry.go @@ -5,7 +5,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "net" "net/url" "os" @@ -547,7 +547,7 @@ func NewPartialChainControl(cfg *Config) (*PartialChainControl, func(), error) { if err != nil { return nil, nil, err } - rpcCert, err = ioutil.ReadAll(certFile) + rpcCert, err = io.ReadAll(certFile) if err != nil { return nil, nil, err } diff --git a/channeldb/migration/lnwire21/announcement_signatures.go b/channeldb/migration/lnwire21/announcement_signatures.go index 639704de0..4c2166a8d 100644 --- a/channeldb/migration/lnwire21/announcement_signatures.go +++ b/channeldb/migration/lnwire21/announcement_signatures.go @@ -2,7 +2,6 @@ package lnwire import ( "io" - "io/ioutil" ) // 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 // aren't any bytes, then we'll snip off the slice to avoid carrying // around excess capacity. - a.ExtraOpaqueData, err = ioutil.ReadAll(r) + a.ExtraOpaqueData, err = io.ReadAll(r) if err != nil { return err } diff --git a/channeldb/migration/lnwire21/channel_announcement.go b/channeldb/migration/lnwire21/channel_announcement.go index 46efeed88..897844fb1 100644 --- a/channeldb/migration/lnwire21/channel_announcement.go +++ b/channeldb/migration/lnwire21/channel_announcement.go @@ -3,7 +3,6 @@ package lnwire import ( "bytes" "io" - "io/ioutil" "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 // aren't any bytes, then we'll snip off the slice to avoid carrying // around excess capacity. - a.ExtraOpaqueData, err = ioutil.ReadAll(r) + a.ExtraOpaqueData, err = io.ReadAll(r) if err != nil { return err } diff --git a/channeldb/migration/lnwire21/channel_update.go b/channeldb/migration/lnwire21/channel_update.go index 6d19e3e4c..77e65e76b 100644 --- a/channeldb/migration/lnwire21/channel_update.go +++ b/channeldb/migration/lnwire21/channel_update.go @@ -4,7 +4,6 @@ import ( "bytes" "fmt" "io" - "io/ioutil" "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 // aren't any bytes, then we'll snip off the slice to avoid carrying // around excess capacity. - a.ExtraOpaqueData, err = ioutil.ReadAll(r) + a.ExtraOpaqueData, err = io.ReadAll(r) if err != nil { return err } diff --git a/channeldb/migration/lnwire21/node_announcement.go b/channeldb/migration/lnwire21/node_announcement.go index 8550fddd3..51cf7367b 100644 --- a/channeldb/migration/lnwire21/node_announcement.go +++ b/channeldb/migration/lnwire21/node_announcement.go @@ -5,7 +5,6 @@ import ( "fmt" "image/color" "io" - "io/ioutil" "net" "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 // aren't any bytes, then we'll snip off the slice to avoid carrying // around excess capacity. - a.ExtraOpaqueData, err = ioutil.ReadAll(r) + a.ExtraOpaqueData, err = io.ReadAll(r) if err != nil { return err } diff --git a/cmd/lncli/cmd_payments.go b/cmd/lncli/cmd_payments.go index 550bb8f3e..f9d01ad60 100644 --- a/cmd/lncli/cmd_payments.go +++ b/cmd/lncli/cmd_payments.go @@ -7,7 +7,7 @@ import ( "encoding/hex" "errors" "fmt" - "io/ioutil" + "io" "os" "runtime" "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 set of target routes. case args.Present() && args.First() == "-": - b, err := ioutil.ReadAll(os.Stdin) + b, err := io.ReadAll(os.Stdin) if err != nil { return err } diff --git a/config.go b/config.go index f746be041..8a347948b 100644 --- a/config.go +++ b/config.go @@ -8,6 +8,7 @@ import ( "encoding/hex" "errors" "fmt" + "io" "io/ioutil" "net" "os" @@ -2006,7 +2007,7 @@ func extractBtcdRPCParams(btcdConfigPath string) (string, string, error) { // With the file open extract the contents of the configuration file so // we can attempt to locate the RPC credentials. - configContents, err := ioutil.ReadAll(btcdConfigFile) + configContents, err := io.ReadAll(btcdConfigFile) if err != nil { return "", "", err } @@ -2056,7 +2057,7 @@ func extractBitcoindRPCParams(networkName, bitcoindDataDir, bitcoindConfigPath, // With the file open extract the contents of the configuration file so // we can attempt to locate the RPC credentials. - configContents, err := ioutil.ReadAll(bitcoindConfigFile) + configContents, err := io.ReadAll(bitcoindConfigFile) if err != nil { return "", "", "", "", err } diff --git a/contractcourt/htlc_incoming_contest_resolver_test.go b/contractcourt/htlc_incoming_contest_resolver_test.go index a87b1991c..6c4ba6bc4 100644 --- a/contractcourt/htlc_incoming_contest_resolver_test.go +++ b/contractcourt/htlc_incoming_contest_resolver_test.go @@ -3,7 +3,6 @@ package contractcourt import ( "bytes" "io" - "io/ioutil" "testing" sphinx "github.com/lightningnetwork/lightning-onion" @@ -291,7 +290,7 @@ type mockOnionProcessor struct { func (o *mockOnionProcessor) ReconstructHopIterator(r io.Reader, rHash []byte, _ hop.ReconstructBlindingInfo) (hop.Iterator, error) { - data, err := ioutil.ReadAll(r) + data, err := io.ReadAll(r) if err != nil { return nil, err }