mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
This commit is contained in:
parent
1e7e160d07
commit
f8c659b62f
67 changed files with 255 additions and 290 deletions
|
|
@ -8,7 +8,6 @@ import (
|
|||
"bytes"
|
||||
"fmt"
|
||||
"internal/testenv"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
|
|
@ -24,7 +23,7 @@ func TestLargeBranch(t *testing.T) {
|
|||
}
|
||||
testenv.MustHaveGoBuild(t)
|
||||
|
||||
dir, err := ioutil.TempDir("", "testlargebranch")
|
||||
dir, err := os.MkdirTemp("", "testlargebranch")
|
||||
if err != nil {
|
||||
t.Fatalf("Could not create directory: %v", err)
|
||||
}
|
||||
|
|
@ -35,7 +34,7 @@ func TestLargeBranch(t *testing.T) {
|
|||
genLargeBranch(buf)
|
||||
|
||||
tmpfile := filepath.Join(dir, "x.s")
|
||||
if err := ioutil.WriteFile(tmpfile, buf.Bytes(), 0644); err != nil {
|
||||
if err := os.WriteFile(tmpfile, buf.Bytes(), 0644); err != nil {
|
||||
t.Fatalf("Failed to write file: %v", err)
|
||||
}
|
||||
|
||||
|
|
@ -67,13 +66,13 @@ func TestLargeCall(t *testing.T) {
|
|||
}
|
||||
testenv.MustHaveGoBuild(t)
|
||||
|
||||
dir, err := ioutil.TempDir("", "testlargecall")
|
||||
dir, err := os.MkdirTemp("", "testlargecall")
|
||||
if err != nil {
|
||||
t.Fatalf("could not create directory: %v", err)
|
||||
}
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
if err := ioutil.WriteFile(filepath.Join(dir, "go.mod"), []byte("module largecall"), 0644); err != nil {
|
||||
if err := os.WriteFile(filepath.Join(dir, "go.mod"), []byte("module largecall"), 0644); err != nil {
|
||||
t.Fatalf("Failed to write file: %v\n", err)
|
||||
}
|
||||
main := `package main
|
||||
|
|
@ -84,7 +83,7 @@ func main() {
|
|||
func x()
|
||||
func y()
|
||||
`
|
||||
if err := ioutil.WriteFile(filepath.Join(dir, "x.go"), []byte(main), 0644); err != nil {
|
||||
if err := os.WriteFile(filepath.Join(dir, "x.go"), []byte(main), 0644); err != nil {
|
||||
t.Fatalf("failed to write main: %v\n", err)
|
||||
}
|
||||
|
||||
|
|
@ -92,7 +91,7 @@ func y()
|
|||
buf := bytes.NewBuffer(make([]byte, 0, 7000000))
|
||||
genLargeCall(buf)
|
||||
|
||||
if err := ioutil.WriteFile(filepath.Join(dir, "x.s"), buf.Bytes(), 0644); err != nil {
|
||||
if err := os.WriteFile(filepath.Join(dir, "x.s"), buf.Bytes(), 0644); err != nil {
|
||||
t.Fatalf("Failed to write file: %v\n", err)
|
||||
}
|
||||
|
||||
|
|
@ -130,13 +129,13 @@ func genLargeCall(buf *bytes.Buffer) {
|
|||
|
||||
// Issue 20348.
|
||||
func TestNoRet(t *testing.T) {
|
||||
dir, err := ioutil.TempDir("", "testnoret")
|
||||
dir, err := os.MkdirTemp("", "testnoret")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.RemoveAll(dir)
|
||||
tmpfile := filepath.Join(dir, "x.s")
|
||||
if err := ioutil.WriteFile(tmpfile, []byte("TEXT ·stub(SB),$0-0\nNOP\n"), 0644); err != nil {
|
||||
if err := os.WriteFile(tmpfile, []byte("TEXT ·stub(SB),$0-0\nNOP\n"), 0644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cmd := exec.Command(testenv.GoToolPath(t), "tool", "asm", "-o", filepath.Join(dir, "x.o"), tmpfile)
|
||||
|
|
@ -147,7 +146,7 @@ func TestNoRet(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestImmediateSplitting(t *testing.T) {
|
||||
dir, err := ioutil.TempDir("", "testimmsplit")
|
||||
dir, err := os.MkdirTemp("", "testimmsplit")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -190,7 +189,7 @@ TEXT _stub(SB),$0-0
|
|||
MOVF F6, 4096(X5)
|
||||
MOVD F6, 4096(X5)
|
||||
`
|
||||
if err := ioutil.WriteFile(tmpfile, []byte(asm), 0644); err != nil {
|
||||
if err := os.WriteFile(tmpfile, []byte(asm), 0644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cmd := exec.Command(testenv.GoToolPath(t), "tool", "asm", "-o", filepath.Join(dir, "x.o"), tmpfile)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue