Merge pull request #7765 from ErikEk/retire-io-ioutil-dep
Remove io/ioutil package dependency
This commit is contained in:
46 files changed
+101
-128
No files matched your search
@@ -4,8 +4,8 @@ import (
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"unicode"
|
||||
@@ -192,7 +192,7 @@ func bakeMacaroon(ctx *cli.Context) error {
|
||||
// a file or write to the standard output using hex encoding.
|
||||
switch {
|
||||
case savePath != "":
|
||||
err = ioutil.WriteFile(savePath, macBytes, 0644)
|
||||
err = os.WriteFile(savePath, macBytes, 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -352,7 +352,7 @@ func printMacaroon(ctx *cli.Context) error {
|
||||
macPath := lncfg.CleanAndExpandPath(ctx.String("macaroon_file"))
|
||||
|
||||
// Load the specified macaroon file.
|
||||
macBytes, err = ioutil.ReadFile(macPath)
|
||||
macBytes, err = os.ReadFile(macPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to read macaroon path %v: %v",
|
||||
macPath, err)
|
||||
@@ -441,7 +441,7 @@ func constrainMacaroon(ctx *cli.Context) error {
|
||||
sourceMacFile := lncfg.CleanAndExpandPath(args.First())
|
||||
args = args.Tail()
|
||||
|
||||
sourceMacBytes, err := ioutil.ReadFile(sourceMacFile)
|
||||
sourceMacBytes, err := os.ReadFile(sourceMacFile)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error trying to read source macaroon file "+
|
||||
"%s: %v", sourceMacFile, err)
|
||||
@@ -471,7 +471,7 @@ func constrainMacaroon(ctx *cli.Context) error {
|
||||
}
|
||||
|
||||
// Now we can output the result.
|
||||
err = ioutil.WriteFile(destMacFile, destMacBytes, 0644)
|
||||
err = os.WriteFile(destMacFile, destMacBytes, 0644)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error writing destination macaroon file "+
|
||||
"%s: %v", destMacFile, err)
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -1016,7 +1015,7 @@ func readTerminalOrFile(quit chan struct{}) (string, error) {
|
||||
|
||||
// If it's a path to an existing file and it's small enough, let's try
|
||||
// to read its content now.
|
||||
content, err := ioutil.ReadFile(maybeFile)
|
||||
content, err := os.ReadFile(maybeFile)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
@@ -423,7 +422,7 @@ func profileAddMacaroon(ctx *cli.Context) error {
|
||||
|
||||
// Now load and possibly encrypt the macaroon file.
|
||||
macPath := lncfg.CleanAndExpandPath(ctx.GlobalString("macaroonpath"))
|
||||
macBytes, err := ioutil.ReadFile(macPath)
|
||||
macBytes, err := os.ReadFile(macPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to read macaroon path: %w", err)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -712,7 +711,7 @@ func createWatchOnly(ctx *cli.Context) error {
|
||||
}
|
||||
|
||||
jsonFile := lncfg.CleanAndExpandPath(ctx.Args().First())
|
||||
jsonBytes, err := ioutil.ReadFile(jsonFile)
|
||||
jsonBytes, err := os.ReadFile(jsonFile)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error reading JSON from file %v: %v",
|
||||
jsonFile, err)
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"os"
|
||||
"strconv"
|
||||
@@ -2833,7 +2832,7 @@ func parseChanBackups(ctx *cli.Context) (*lnrpc.RestoreChanBackupRequest, error)
|
||||
}, nil
|
||||
|
||||
case ctx.IsSet("multi_file"):
|
||||
packedMulti, err := ioutil.ReadFile(ctx.String("multi_file"))
|
||||
packedMulti, err := os.ReadFile(ctx.String("multi_file"))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to decode multi packed "+
|
||||
"backup: %v", err)
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
@@ -129,7 +129,7 @@ func profileFromContext(ctx *cli.Context, store, skipMacaroons bool) (
|
||||
var tlsCert []byte
|
||||
if tlsCertPath != "" && !insecure {
|
||||
var err error
|
||||
tlsCert, err = ioutil.ReadFile(tlsCertPath)
|
||||
tlsCert, err = os.ReadFile(tlsCertPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not load TLS cert "+
|
||||
"file: %v", err)
|
||||
@@ -167,7 +167,7 @@ func profileFromContext(ctx *cli.Context, store, skipMacaroons bool) (
|
||||
}
|
||||
|
||||
// Now load and possibly encrypt the macaroon file.
|
||||
macBytes, err := ioutil.ReadFile(macPath)
|
||||
macBytes, err := os.ReadFile(macPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to read macaroon path (check "+
|
||||
"the network setting!): %v", err)
|
||||
@@ -222,7 +222,7 @@ func loadProfileFile(file string) (*profileFile, error) {
|
||||
return nil, errNoProfileFile
|
||||
}
|
||||
|
||||
content, err := ioutil.ReadFile(file)
|
||||
content, err := os.ReadFile(file)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not load profile file %s: %w",
|
||||
file, err)
|
||||
@@ -243,7 +243,8 @@ func saveProfileFile(file string, f *profileFile) error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not marshal profile: %w", err)
|
||||
}
|
||||
return ioutil.WriteFile(file, content, 0644)
|
||||
|
||||
return os.WriteFile(file, content, 0644)
|
||||
}
|
||||
|
||||
// profileFile is a struct that represents the whole content of a profile file.
|
||||
|
||||
Reference in new issue
Block a user