diff options
author | Russ Cox <rsc@golang.org> | 2020-10-29 14:17:47 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2020-12-09 19:12:23 +0000 |
commit | 4f1b0a44cb46f3df28f5ef82e5769ebeac1bc493 (patch) | |
tree | c186cc25257b05fcb21cd8c1f1ee5961ebef6eb3 /src/index | |
parent | 5627a4dc3013fed02c4b8097413643b682cac276 (diff) | |
download | go-4f1b0a44cb46f3df28f5ef82e5769ebeac1bc493.tar.gz go-4f1b0a44cb46f3df28f5ef82e5769ebeac1bc493.zip |
all: update to use os.ReadFile, os.WriteFile, os.CreateTemp, os.MkdirTemp
As part of #42026, these helpers from io/ioutil were moved to os.
(ioutil.TempFile and TempDir became os.CreateTemp and MkdirTemp.)
Update the Go tree to use the preferred names.
As usual, code compiled with the Go 1.4 bootstrap toolchain
and code vendored from other sources is excluded.
ReadDir changes are in a separate CL, because they are not a
simple search and replace.
For #42026.
Change-Id: If318df0216d57e95ea0c4093b89f65e5b0ababb3
Reviewed-on: https://go-review.googlesource.com/c/go/+/266365
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/index')
-rw-r--r-- | src/index/suffixarray/gen.go | 6 | ||||
-rw-r--r-- | src/index/suffixarray/suffixarray_test.go | 6 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/index/suffixarray/gen.go b/src/index/suffixarray/gen.go index 8c3de553c9..94184d71b6 100644 --- a/src/index/suffixarray/gen.go +++ b/src/index/suffixarray/gen.go @@ -11,8 +11,8 @@ package main import ( "bytes" - "io/ioutil" "log" + "os" "strings" ) @@ -20,7 +20,7 @@ func main() { log.SetPrefix("gen: ") log.SetFlags(0) - data, err := ioutil.ReadFile("sais.go") + data, err := os.ReadFile("sais.go") if err != nil { log.Fatal(err) } @@ -64,7 +64,7 @@ func main() { } } - if err := ioutil.WriteFile("sais2.go", buf.Bytes(), 0666); err != nil { + if err := os.WriteFile("sais2.go", buf.Bytes(), 0666); err != nil { log.Fatal(err) } } diff --git a/src/index/suffixarray/suffixarray_test.go b/src/index/suffixarray/suffixarray_test.go index a11a98dae0..44c5041535 100644 --- a/src/index/suffixarray/suffixarray_test.go +++ b/src/index/suffixarray/suffixarray_test.go @@ -8,8 +8,8 @@ import ( "bytes" "fmt" "io/fs" - "io/ioutil" "math/rand" + "os" "path/filepath" "regexp" "sort" @@ -498,14 +498,14 @@ func makeText(name string) ([]byte, error) { switch name { case "opticks": var err error - data, err = ioutil.ReadFile("../../testdata/Isaac.Newton-Opticks.txt") + data, err = os.ReadFile("../../testdata/Isaac.Newton-Opticks.txt") if err != nil { return nil, err } case "go": err := filepath.WalkDir("../..", func(path string, info fs.DirEntry, err error) error { if err == nil && strings.HasSuffix(path, ".go") && !info.IsDir() { - file, err := ioutil.ReadFile(path) + file, err := os.ReadFile(path) if err != nil { return err } |