aboutsummaryrefslogtreecommitdiff
path: root/src/internal/fuzz
diff options
context:
space:
mode:
authorAndy Pan <panjf2000@gmail.com>2022-08-28 03:38:00 +0800
committerGopher Robot <gobot@golang.org>2022-09-20 02:13:02 +0000
commitf8c659b62ff43e8455ebc675e577b9adc67b3f9f (patch)
tree967f364a5943aa7323224d56a2eb5c969a81ddbe /src/internal/fuzz
parent1e7e160d070443147ee38d4de530ce904637a4f3 (diff)
downloadgo-f8c659b62ff43e8455ebc675e577b9adc67b3f9f.tar.xz
all: replace package ioutil with os and io in src
For #45557 Change-Id: I56824135d86452603dd4ed4bab0e24c201bb0683 Reviewed-on: https://go-review.googlesource.com/c/go/+/426257 Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Andy Pan <panjf2000@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/internal/fuzz')
-rw-r--r--src/internal/fuzz/fuzz.go7
-rw-r--r--src/internal/fuzz/mem.go3
-rw-r--r--src/internal/fuzz/worker.go3
3 files changed, 5 insertions, 8 deletions
diff --git a/src/internal/fuzz/fuzz.go b/src/internal/fuzz/fuzz.go
index 3ccf74745f..9ce39cbcf0 100644
--- a/src/internal/fuzz/fuzz.go
+++ b/src/internal/fuzz/fuzz.go
@@ -14,7 +14,6 @@ import (
"fmt"
"internal/godebug"
"io"
- "io/ioutil"
"math/bits"
"os"
"path/filepath"
@@ -963,7 +962,7 @@ func (e *MalformedCorpusError) Error() string {
// be saved in a MalformedCorpusError and returned, along with the most recent
// error.
func ReadCorpus(dir string, types []reflect.Type) ([]CorpusEntry, error) {
- files, err := ioutil.ReadDir(dir)
+ files, err := os.ReadDir(dir)
if os.IsNotExist(err) {
return nil, nil // No corpus to read
} else if err != nil {
@@ -981,7 +980,7 @@ func ReadCorpus(dir string, types []reflect.Type) ([]CorpusEntry, error) {
continue
}
filename := filepath.Join(dir, file.Name())
- data, err := ioutil.ReadFile(filename)
+ data, err := os.ReadFile(filename)
if err != nil {
return nil, fmt.Errorf("failed to read corpus file: %v", err)
}
@@ -1038,7 +1037,7 @@ func writeToCorpus(entry *CorpusEntry, dir string) (err error) {
if err := os.MkdirAll(dir, 0777); err != nil {
return err
}
- if err := ioutil.WriteFile(entry.Path, entry.Data, 0666); err != nil {
+ if err := os.WriteFile(entry.Path, entry.Data, 0666); err != nil {
os.Remove(entry.Path) // remove partially written file
return err
}
diff --git a/src/internal/fuzz/mem.go b/src/internal/fuzz/mem.go
index a5c3b02242..ea29b60607 100644
--- a/src/internal/fuzz/mem.go
+++ b/src/internal/fuzz/mem.go
@@ -6,7 +6,6 @@ package fuzz
import (
"fmt"
- "io/ioutil"
"os"
"unsafe"
)
@@ -65,7 +64,7 @@ func sharedMemSize(valueSize int) int {
// it into memory. The file will be removed when the Close method is called.
func sharedMemTempFile(size int) (m *sharedMem, err error) {
// Create a temporary file.
- f, err := ioutil.TempFile("", "fuzz-*")
+ f, err := os.CreateTemp("", "fuzz-*")
if err != nil {
return nil, err
}
diff --git a/src/internal/fuzz/worker.go b/src/internal/fuzz/worker.go
index 6e4c4e2d0f..fca3aea578 100644
--- a/src/internal/fuzz/worker.go
+++ b/src/internal/fuzz/worker.go
@@ -12,7 +12,6 @@ import (
"errors"
"fmt"
"io"
- "io/ioutil"
"os"
"os/exec"
"reflect"
@@ -958,7 +957,7 @@ func (wc *workerClient) Close() error {
// Drain fuzzOut and close it. When the server exits, the kernel will close
// its end of fuzzOut, and we'll get EOF.
- if _, err := io.Copy(ioutil.Discard, wc.fuzzOut); err != nil {
+ if _, err := io.Copy(io.Discard, wc.fuzzOut); err != nil {
wc.fuzzOut.Close()
return err
}