diff --git a/builder/builder_test.go b/builder/builder_test.go index 42727e4a..3b0ae8bc 100644 --- a/builder/builder_test.go +++ b/builder/builder_test.go @@ -2,7 +2,6 @@ package builder import ( "fmt" - "io/ioutil" "os" "path/filepath" "runtime" @@ -90,7 +89,7 @@ func testClangAttributes(t *testing.T, options *compileopts.Options) { // Create a very simple C input file. srcpath := filepath.Join(testDir, "test.c") - err = ioutil.WriteFile(srcpath, []byte("int add(int a, int b) { return a + b; }"), 0o666) + err = os.WriteFile(srcpath, []byte("int add(int a, int b) { return a + b; }"), 0o666) if err != nil { t.Fatalf("could not write target file %s: %s", srcpath, err) } diff --git a/cgo/cgo_test.go b/cgo/cgo_test.go index cbb0f589..c542df7f 100644 --- a/cgo/cgo_test.go +++ b/cgo/cgo_test.go @@ -10,7 +10,7 @@ import ( "go/parser" "go/token" "go/types" - "io/ioutil" + "os" "path/filepath" "runtime" "strings" @@ -107,7 +107,7 @@ func TestCGo(t *testing.T) { // Read the file with the expected output, to compare against. outfile := filepath.Join("testdata", name+".out.go") - expectedBytes, err := ioutil.ReadFile(outfile) + expectedBytes, err := os.ReadFile(outfile) if err != nil { t.Fatalf("could not read expected output: %v", err) } @@ -118,7 +118,7 @@ func TestCGo(t *testing.T) { // It is not. Test failed. if *flagUpdate { // Update the file with the expected data. - err := ioutil.WriteFile(outfile, []byte(actual), 0666) + err := os.WriteFile(outfile, []byte(actual), 0666) if err != nil { t.Error("could not write updated output file:", err) } diff --git a/compiler/compiler_test.go b/compiler/compiler_test.go index cee023cd..e115cf95 100644 --- a/compiler/compiler_test.go +++ b/compiler/compiler_test.go @@ -3,7 +3,7 @@ package compiler import ( "flag" "go/types" - "io/ioutil" + "os" "strconv" "strings" "testing" @@ -162,14 +162,14 @@ func TestCompiler(t *testing.T) { // Update test if needed. Do not check the result. if *flagUpdate { - err := ioutil.WriteFile(outPath, []byte(mod.String()), 0666) + err := os.WriteFile(outPath, []byte(mod.String()), 0666) if err != nil { t.Error("failed to write updated output file:", err) } return } - expected, err := ioutil.ReadFile(outPath) + expected, err := os.ReadFile(outPath) if err != nil { t.Fatal("failed to read golden file:", err) } diff --git a/interp/interp_test.go b/interp/interp_test.go index 7b2bb619..c4258653 100644 --- a/interp/interp_test.go +++ b/interp/interp_test.go @@ -1,7 +1,6 @@ package interp import ( - "io/ioutil" "os" "strconv" "strings" @@ -87,7 +86,7 @@ func runTest(t *testing.T, pathPrefix string) { pm.Run(mod) // Read the expected output IR. - out, err := ioutil.ReadFile(pathPrefix + ".out.ll") + out, err := os.ReadFile(pathPrefix + ".out.ll") if err != nil { t.Fatalf("could not read output file %s: %v", pathPrefix+".out.ll", err) } diff --git a/main_test.go b/main_test.go index f620c77d..310a92fe 100644 --- a/main_test.go +++ b/main_test.go @@ -10,7 +10,6 @@ import ( "flag" "fmt" "io" - "io/ioutil" "os" "os/exec" "reflect" @@ -319,7 +318,7 @@ func runTestWithConfig(name string, t *testing.T, options compileopts.Options, c if path[len(path)-1] == '/' { txtpath = path + "out.txt" } - expected, err := ioutil.ReadFile(txtpath) + expected, err := os.ReadFile(txtpath) if err != nil { t.Fatal("could not read expected output file:", err) } diff --git a/src/os/os_anyos_test.go b/src/os/os_anyos_test.go index d8ac01c2..dd255fb4 100644 --- a/src/os/os_anyos_test.go +++ b/src/os/os_anyos_test.go @@ -5,7 +5,7 @@ package os_test import ( "io/fs" - "io/ioutil" + "os" . "os" "path/filepath" "runtime" @@ -198,13 +198,13 @@ func TestRenameOverwriteDest(t *testing.T) { toData := []byte("to") fromData := []byte("from") - err := ioutil.WriteFile(to, toData, 0777) + err := os.WriteFile(to, toData, 0777) defer Remove(to) // TODO: switch to t.Tempdir, remove this line if err != nil { t.Fatalf("write file %q failed: %v", to, err) } - err = ioutil.WriteFile(from, fromData, 0777) + err = os.WriteFile(from, fromData, 0777) defer Remove(from) // TODO: switch to t.Tempdir, remove this line if err != nil { t.Fatalf("write file %q failed: %v", from, err) diff --git a/src/os/os_test.go b/src/os/os_test.go index bf1a1735..d79ad4a3 100644 --- a/src/os/os_test.go +++ b/src/os/os_test.go @@ -6,7 +6,7 @@ package os_test import ( "io" - "io/ioutil" + "os" . "os" "runtime" "strings" @@ -129,7 +129,7 @@ func TestSeek(t *testing.T) { off, err := f.Seek(tt.in, tt.whence) if off != tt.out || err != nil { if e, ok := err.(*PathError); ok && e.Err == syscall.EINVAL && tt.out > 1<<32 && runtime.GOOS == "linux" { - mounts, _ := ioutil.ReadFile("/proc/mounts") + mounts, _ := os.ReadFile("/proc/mounts") if strings.Contains(string(mounts), "reiserfs") { // Reiserfs rejects the big seeks. t.Skipf("skipping test known to fail on reiserfs; https://golang.org/issue/91") diff --git a/transform/allocs_test.go b/transform/allocs_test.go index f4c86f66..27bb9706 100644 --- a/transform/allocs_test.go +++ b/transform/allocs_test.go @@ -2,7 +2,7 @@ package transform_test import ( "go/token" - "io/ioutil" + "os" "path/filepath" "regexp" "sort" @@ -62,7 +62,7 @@ func TestAllocs2(t *testing.T) { } // Load expected test output (the OUT: lines). - testInput, err := ioutil.ReadFile("./testdata/allocs2.go") + testInput, err := os.ReadFile("./testdata/allocs2.go") if err != nil { t.Fatal("could not read test input:", err) } diff --git a/transform/transform_test.go b/transform/transform_test.go index 1c6b5df3..4cab255e 100644 --- a/transform/transform_test.go +++ b/transform/transform_test.go @@ -6,7 +6,6 @@ import ( "flag" "go/token" "go/types" - "io/ioutil" "os" "path/filepath" "strings" @@ -58,13 +57,13 @@ func testTransform(t *testing.T, pathPrefix string, transform func(mod llvm.Modu actual = actual[strings.Index(actual, "\ntarget datalayout = ")+1:] if *update { - err := ioutil.WriteFile(pathPrefix+".out.ll", []byte(actual), 0666) + err := os.WriteFile(pathPrefix+".out.ll", []byte(actual), 0666) if err != nil { t.Error("failed to write out new output:", err) } } else { // Read the expected output IR. - out, err := ioutil.ReadFile(pathPrefix + ".out.ll") + out, err := os.ReadFile(pathPrefix + ".out.ll") if err != nil { t.Fatalf("could not read output file %s: %v", pathPrefix+".out.ll", err) }