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/cmd/fix | |
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/cmd/fix')
-rw-r--r-- | src/cmd/fix/main.go | 3 | ||||
-rw-r--r-- | src/cmd/fix/typecheck.go | 7 |
2 files changed, 4 insertions, 6 deletions
diff --git a/src/cmd/fix/main.go b/src/cmd/fix/main.go index 1cedf992cf..d055929aac 100644 --- a/src/cmd/fix/main.go +++ b/src/cmd/fix/main.go @@ -15,7 +15,6 @@ import ( "go/token" "io" "io/fs" - "io/ioutil" "os" "path/filepath" "sort" @@ -217,7 +216,7 @@ func processFile(filename string, useStdin bool) error { return nil } - return ioutil.WriteFile(f.Name(), newSrc, 0) + return os.WriteFile(f.Name(), newSrc, 0) } func gofmt(n interface{}) string { diff --git a/src/cmd/fix/typecheck.go b/src/cmd/fix/typecheck.go index f45155b06d..40b2287f26 100644 --- a/src/cmd/fix/typecheck.go +++ b/src/cmd/fix/typecheck.go @@ -9,7 +9,6 @@ import ( "go/ast" "go/parser" "go/token" - "io/ioutil" "os" "os/exec" "path/filepath" @@ -162,12 +161,12 @@ func typecheck(cfg *TypeConfig, f *ast.File) (typeof map[interface{}]string, ass if err != nil { return err } - dir, err := ioutil.TempDir(os.TempDir(), "fix_cgo_typecheck") + dir, err := os.MkdirTemp(os.TempDir(), "fix_cgo_typecheck") if err != nil { return err } defer os.RemoveAll(dir) - err = ioutil.WriteFile(filepath.Join(dir, "in.go"), txt, 0600) + err = os.WriteFile(filepath.Join(dir, "in.go"), txt, 0600) if err != nil { return err } @@ -176,7 +175,7 @@ func typecheck(cfg *TypeConfig, f *ast.File) (typeof map[interface{}]string, ass if err != nil { return err } - out, err := ioutil.ReadFile(filepath.Join(dir, "_cgo_gotypes.go")) + out, err := os.ReadFile(filepath.Join(dir, "_cgo_gotypes.go")) if err != nil { return err } |