all: replace uses of ioutil with io and os (#24869)
This commit is contained in:
@@ -20,9 +20,9 @@ import (
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math/big"
|
||||
"math/rand"
|
||||
"os"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
@@ -852,7 +852,7 @@ func TestDeriveLogFields(t *testing.T) {
|
||||
|
||||
func BenchmarkDecodeRLPLogs(b *testing.B) {
|
||||
// Encoded receipts from block 0x14ee094309fbe8f70b65f45ebcc08fb33f126942d97464aad5eb91cfd1e2d269
|
||||
buf, err := ioutil.ReadFile("testdata/stored_receipts.bin")
|
||||
buf, err := os.ReadFile("testdata/stored_receipts.bin")
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -17,13 +17,12 @@
|
||||
package rawdb
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestReadWriteFreezerTableMeta(t *testing.T) {
|
||||
f, err := ioutil.TempFile(os.TempDir(), "*")
|
||||
f, err := os.CreateTemp(os.TempDir(), "*")
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create file %v", err)
|
||||
}
|
||||
@@ -44,7 +43,7 @@ func TestReadWriteFreezerTableMeta(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestInitializeFreezerTableMeta(t *testing.T) {
|
||||
f, err := ioutil.TempFile(os.TempDir(), "*")
|
||||
f, err := os.CreateTemp(os.TempDir(), "*")
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create file %v", err)
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ package rawdb
|
||||
|
||||
import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
@@ -30,7 +29,7 @@ import (
|
||||
// It is perfectly valid to have destPath == srcPath.
|
||||
func copyFrom(srcPath, destPath string, offset uint64, before func(f *os.File) error) error {
|
||||
// Create a temp file in the same dir where we want it to wind up
|
||||
f, err := ioutil.TempFile(filepath.Dir(destPath), "*")
|
||||
f, err := os.CreateTemp(filepath.Dir(destPath), "*")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ package rawdb
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
@@ -44,7 +43,7 @@ func TestCopyFrom(t *testing.T) {
|
||||
{"foo", "bar", 8, true},
|
||||
}
|
||||
for _, c := range cases {
|
||||
ioutil.WriteFile(c.src, content, 0644)
|
||||
os.WriteFile(c.src, content, 0644)
|
||||
|
||||
if err := copyFrom(c.src, c.dest, c.offset, func(f *os.File) error {
|
||||
if !c.writePrefix {
|
||||
@@ -57,7 +56,7 @@ func TestCopyFrom(t *testing.T) {
|
||||
t.Fatalf("Failed to copy %v", err)
|
||||
}
|
||||
|
||||
blob, err := ioutil.ReadFile(c.dest)
|
||||
blob, err := os.ReadFile(c.dest)
|
||||
if err != nil {
|
||||
os.Remove(c.src)
|
||||
os.Remove(c.dest)
|
||||
|
||||
Reference in New Issue
Block a user