Merge pull request #7765 from ErikEk/retire-io-ioutil-dep

Remove io/ioutil package dependency
This commit is contained in:
Oliver Gugger authored and GitHub committed 2024-04-25 13:17:15 +02:00
commit 2089a88f4b
46 files changed
+101 -128

No files matched your search

+1 -2
View File
@@ -6,7 +6,6 @@ package lntest
import (
"errors"
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
@@ -105,7 +104,7 @@ func newBackend(miner string, netParams *chaincfg.Params, extraArgs []string,
return nil, nil, err
}
tempBitcoindDir, err := ioutil.TempDir("", "bitcoind")
tempBitcoindDir, err := os.MkdirTemp("", "bitcoind")
if err != nil {
return nil, nil,
fmt.Errorf("unable to create temp directory: %w", err)
+1 -2
View File
@@ -7,7 +7,6 @@ import (
"encoding/hex"
"errors"
"fmt"
"io/ioutil"
"os"
"strings"
@@ -135,7 +134,7 @@ func NewBackend(miner string, netParams *chaincfg.Params) (
// the log files, including any compressed log files from
// logrorate, before deleting the temporary log dir.
logDir := fmt.Sprintf("%s/%s", baseLogDir, netParams.Name)
files, err := ioutil.ReadDir(logDir)
files, err := os.ReadDir(logDir)
if err != nil {
errStr += fmt.Sprintf(
"unable to read log directory: %v\n", err,
+1 -2
View File
@@ -4,7 +4,6 @@ import (
"bytes"
"context"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
@@ -121,7 +120,7 @@ func (h *HarnessMiner) saveLogs() {
// After shutting down the miner, we'll make a copy of the log files
// before deleting the temporary log dir.
path := fmt.Sprintf("%s/%s", h.logPath, harnessNetParams.Name)
files, err := ioutil.ReadDir(path)
files, err := os.ReadDir(path)
require.NoError(h, err, "unable to read log directory")
for _, file := range files {
+3 -4
View File
@@ -9,7 +9,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
@@ -297,7 +296,7 @@ func (hn *HarnessNode) ReadMacaroon(macPath string, timeout time.Duration) (
// using it.
var mac *macaroon.Macaroon
err := wait.NoError(func() error {
macBytes, err := ioutil.ReadFile(macPath)
macBytes, err := os.ReadFile(macPath)
if err != nil {
return fmt.Errorf("error reading macaroon file: %w",
err)
@@ -824,7 +823,7 @@ func (hn *HarnessNode) BackupDB() error {
}
} else {
// Backup files.
tempDir, err := ioutil.TempDir("", "past-state")
tempDir, err := os.MkdirTemp("", "past-state")
if err != nil {
return fmt.Errorf("unable to create temp db folder: %w",
err)
@@ -1032,7 +1031,7 @@ func addLogFile(hn *HarnessNode) error {
// copyAll copies all files and directories from srcDir to dstDir recursively.
// Note that this function does not support links.
func copyAll(dstDir, srcDir string) error {
entries, err := ioutil.ReadDir(srcDir)
entries, err := os.ReadDir(srcDir)
if err != nil {
return err
}