all: replace io/ioutil with io and os package

For golang/go#45557

Change-Id: Ia95cb5fca120899b6643639dabe8e8ae99eaf193
GitHub-Last-Rev: 529b29f971f53560b71650dbc92ed33ef94a8c18
GitHub-Pull-Request: golang/debug#16
Reviewed-on: https://go-review.googlesource.com/c/debug/+/430857
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Meng Zhuo <mzh@golangcn.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Meng Zhuo <mzh@golangcn.org>
diff --git a/dwtest/dwloc_test.go b/dwtest/dwloc_test.go
index a4e85c9..0184c0e 100644
--- a/dwtest/dwloc_test.go
+++ b/dwtest/dwloc_test.go
@@ -28,7 +28,6 @@
 
 import (
 	"bytes"
-	"io/ioutil"
 	"os"
 	"os/exec"
 	"path/filepath"
@@ -53,12 +52,12 @@
 	}
 	cp := func(from, to string) {
 		var payload []byte
-		payload, err := ioutil.ReadFile(from)
+		payload, err := os.ReadFile(from)
 		if err != nil {
-			t.Fatalf("ioutil.ReadFile failed: %v", err)
+			t.Fatalf("os.ReadFile failed: %v", err)
 		}
-		if err = ioutil.WriteFile(to, payload, 0644); err != nil {
-			t.Fatalf("ioutil.WriteFile failed: %v", err)
+		if err = os.WriteFile(to, payload, 0644); err != nil {
+			t.Fatalf("os.WriteFile failed: %v", err)
 		}
 	}
 	join := filepath.Join
@@ -109,7 +108,7 @@
 // Return value is binary path.
 func gobuild(t *testing.T, sourceCode string, pname string) string {
 	spath := filepath.Join(t.TempDir(), pname+".go")
-	if err := ioutil.WriteFile(spath, []byte(sourceCode), 0644); err != nil {
+	if err := os.WriteFile(spath, []byte(sourceCode), 0644); err != nil {
 		t.Fatalf("write to %s failed: %s", spath, err)
 	}
 	epath := filepath.Join(t.TempDir(), pname+".exe")
diff --git a/internal/gocore/gocore_test.go b/internal/gocore/gocore_test.go
index e9a41b8..45ff613 100644
--- a/internal/gocore/gocore_test.go
+++ b/internal/gocore/gocore_test.go
@@ -12,7 +12,6 @@
 	"errors"
 	"fmt"
 	"io"
-	"io/ioutil"
 	"os"
 	"os/exec"
 	"path"
@@ -62,7 +61,7 @@
 	var base string
 	if strings.HasSuffix(version, ".zip") {
 		// Make temporary directory.
-		dir, err := ioutil.TempDir("", strings.TrimSuffix(version, ".zip")+"_")
+		dir, err := os.MkdirTemp("", strings.TrimSuffix(version, ".zip")+"_")
 		if err != nil {
 			t.Fatalf("can't make temp directory: %s", err)
 		}
@@ -433,7 +432,7 @@
 		t.Skip("skipping test on android")
 	}
 	// Make temporary directory.
-	dir, err := ioutil.TempDir("", name+"_")
+	dir, err := os.MkdirTemp("", name+"_")
 	if err != nil {
 		t.Fatalf("can't make temp directory: %s", err)
 	}