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
|
|
@ -9,7 +9,6 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"internal/buildcfg"
|
"internal/buildcfg"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
|
@ -51,7 +50,7 @@ func testEndToEnd(t *testing.T, goarch, file string) {
|
||||||
output := strings.Split(testOut.String(), "\n")
|
output := strings.Split(testOut.String(), "\n")
|
||||||
|
|
||||||
// Reconstruct expected output by independently "parsing" the input.
|
// Reconstruct expected output by independently "parsing" the input.
|
||||||
data, err := ioutil.ReadFile(input)
|
data, err := os.ReadFile(input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
return
|
return
|
||||||
|
|
@ -324,7 +323,7 @@ func testErrors(t *testing.T, goarch, file string, flags ...string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconstruct expected errors by independently "parsing" the input.
|
// Reconstruct expected errors by independently "parsing" the input.
|
||||||
data, err := ioutil.ReadFile(input)
|
data, err := os.ReadFile(input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ import (
|
||||||
"go/token"
|
"go/token"
|
||||||
"internal/buildcfg"
|
"internal/buildcfg"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
@ -345,7 +344,7 @@ func main() {
|
||||||
input = aname
|
input = aname
|
||||||
}
|
}
|
||||||
|
|
||||||
b, err := ioutil.ReadFile(input)
|
b, err := os.ReadFile(input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fatalf("%s", err)
|
fatalf("%s", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"go/token"
|
"go/token"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
)
|
)
|
||||||
|
|
@ -21,13 +20,13 @@ func run(stdin []byte, argv []string) (stdout, stderr []byte, ok bool) {
|
||||||
// Some compilers have trouble with standard input.
|
// Some compilers have trouble with standard input.
|
||||||
// Others have trouble with -xc.
|
// Others have trouble with -xc.
|
||||||
// Avoid both problems by writing a file with a .c extension.
|
// Avoid both problems by writing a file with a .c extension.
|
||||||
f, err := ioutil.TempFile("", "cgo-gcc-input-")
|
f, err := os.CreateTemp("", "cgo-gcc-input-")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fatalf("%s", err)
|
fatalf("%s", err)
|
||||||
}
|
}
|
||||||
name := f.Name()
|
name := f.Name()
|
||||||
f.Close()
|
f.Close()
|
||||||
if err := ioutil.WriteFile(name+".c", stdin, 0666); err != nil {
|
if err := os.WriteFile(name+".c", stdin, 0666); err != nil {
|
||||||
os.Remove(name)
|
os.Remove(name)
|
||||||
fatalf("%s", err)
|
fatalf("%s", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"internal/buildcfg"
|
"internal/buildcfg"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
@ -392,7 +391,7 @@ func readImportCfg(file string) {
|
||||||
Flag.Cfg.ImportMap = make(map[string]string)
|
Flag.Cfg.ImportMap = make(map[string]string)
|
||||||
}
|
}
|
||||||
Flag.Cfg.PackageFile = map[string]string{}
|
Flag.Cfg.PackageFile = map[string]string{}
|
||||||
data, err := ioutil.ReadFile(file)
|
data, err := os.ReadFile(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("-importcfg: %v", err)
|
log.Fatalf("-importcfg: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -432,7 +431,7 @@ func readImportCfg(file string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func readEmbedCfg(file string) {
|
func readEmbedCfg(file string) {
|
||||||
data, err := ioutil.ReadFile(file)
|
data, err := os.ReadFile(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("-embedcfg: %v", err)
|
log.Fatalf("-embedcfg: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ import (
|
||||||
"debug/dwarf"
|
"debug/dwarf"
|
||||||
"fmt"
|
"fmt"
|
||||||
"internal/testenv"
|
"internal/testenv"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -221,7 +220,7 @@ func TestScopeRanges(t *testing.T) {
|
||||||
t.Skip("skipping on plan9; no DWARF symbol table in executables")
|
t.Skip("skipping on plan9; no DWARF symbol table in executables")
|
||||||
}
|
}
|
||||||
|
|
||||||
dir, err := ioutil.TempDir("", "TestScopeRanges")
|
dir, err := os.MkdirTemp("", "TestScopeRanges")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("could not create directory: %v", err)
|
t.Fatalf("could not create directory: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -498,7 +497,7 @@ func TestEmptyDwarfRanges(t *testing.T) {
|
||||||
t.Skip("skipping on plan9; no DWARF symbol table in executables")
|
t.Skip("skipping on plan9; no DWARF symbol table in executables")
|
||||||
}
|
}
|
||||||
|
|
||||||
dir, err := ioutil.TempDir("", "TestEmptyDwarfRanges")
|
dir, err := os.MkdirTemp("", "TestEmptyDwarfRanges")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("could not create directory: %v", err)
|
t.Fatalf("could not create directory: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,15 +7,15 @@ package importer
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"cmd/compile/internal/types2"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"go/build"
|
"go/build"
|
||||||
"internal/pkgbits"
|
"internal/pkgbits"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"cmd/compile/internal/types2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// debugging/development support
|
// debugging/development support
|
||||||
|
|
@ -149,7 +149,7 @@ func Import(packages map[string]*types2.Package, path, srcDir string, lookup fun
|
||||||
if size >= 0 {
|
if size >= 0 {
|
||||||
r = io.LimitReader(r, int64(size))
|
r = io.LimitReader(r, int64(size))
|
||||||
}
|
}
|
||||||
data, err = ioutil.ReadAll(r)
|
data, err = io.ReadAll(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ import (
|
||||||
"go/parser"
|
"go/parser"
|
||||||
"go/token"
|
"go/token"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -160,7 +159,7 @@ func main() {
|
||||||
// write out mangled source so we can see the bug.
|
// write out mangled source so we can see the bug.
|
||||||
out = buf.Bytes()
|
out = buf.Bytes()
|
||||||
}
|
}
|
||||||
err = ioutil.WriteFile("node_gen.go", out, 0666)
|
err = os.WriteFile("node_gen.go", out, 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ package logopt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"internal/testenv"
|
"internal/testenv"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -88,7 +87,7 @@ func TestLogOpt(t *testing.T) {
|
||||||
|
|
||||||
testenv.MustHaveGoBuild(t)
|
testenv.MustHaveGoBuild(t)
|
||||||
|
|
||||||
dir, err := ioutil.TempDir("", "TestLogOpt")
|
dir, err := os.MkdirTemp("", "TestLogOpt")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
@ -96,7 +95,7 @@ func TestLogOpt(t *testing.T) {
|
||||||
|
|
||||||
dir = fixSlash(dir) // Normalize the directory name as much as possible, for Windows testing
|
dir = fixSlash(dir) // Normalize the directory name as much as possible, for Windows testing
|
||||||
src := filepath.Join(dir, "file.go")
|
src := filepath.Join(dir, "file.go")
|
||||||
if err := ioutil.WriteFile(src, []byte(srcCode), 0644); err != nil {
|
if err := os.WriteFile(src, []byte(srcCode), 0644); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -146,7 +145,7 @@ func s15a8(x *[15]int64) [15]int64 {
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
copy := filepath.Join(dir, "copy.go")
|
copy := filepath.Join(dir, "copy.go")
|
||||||
if err := ioutil.WriteFile(copy, []byte(copyCode), 0644); err != nil {
|
if err := os.WriteFile(copy, []byte(copyCode), 0644); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
outcopy := filepath.Join(dir, "copy.o")
|
outcopy := filepath.Join(dir, "copy.o")
|
||||||
|
|
@ -169,7 +168,7 @@ func s15a8(x *[15]int64) [15]int64 {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error("-json=0,file://log/opt should have succeeded")
|
t.Error("-json=0,file://log/opt should have succeeded")
|
||||||
}
|
}
|
||||||
logged, err := ioutil.ReadFile(filepath.Join(dir, "log", "opt", "x", "copy.json"))
|
logged, err := os.ReadFile(filepath.Join(dir, "log", "opt", "x", "copy.json"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error("-json=0,file://log/opt missing expected log file")
|
t.Error("-json=0,file://log/opt missing expected log file")
|
||||||
}
|
}
|
||||||
|
|
@ -196,7 +195,7 @@ func s15a8(x *[15]int64) [15]int64 {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error("-json=0,file://log/opt should have succeeded")
|
t.Error("-json=0,file://log/opt should have succeeded")
|
||||||
}
|
}
|
||||||
logged, err := ioutil.ReadFile(filepath.Join(dir, "log", "opt", "x", "file.json"))
|
logged, err := os.ReadFile(filepath.Join(dir, "log", "opt", "x", "file.json"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error("-json=0,file://log/opt missing expected log file")
|
t.Error("-json=0,file://log/opt missing expected log file")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,20 +8,18 @@ import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"flag"
|
"flag"
|
||||||
"internal/buildcfg"
|
|
||||||
"runtime"
|
|
||||||
"sort"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"internal/buildcfg"
|
||||||
"internal/testenv"
|
"internal/testenv"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"runtime"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -129,7 +127,7 @@ func TestDebugLines_53456(t *testing.T) {
|
||||||
func compileAndDump(t *testing.T, file, function, moreGCFlags string) []byte {
|
func compileAndDump(t *testing.T, file, function, moreGCFlags string) []byte {
|
||||||
testenv.MustHaveGoBuild(t)
|
testenv.MustHaveGoBuild(t)
|
||||||
|
|
||||||
tmpdir, err := ioutil.TempDir("", "debug_lines_test")
|
tmpdir, err := os.MkdirTemp("", "debug_lines_test")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Sprintf("Problem creating TempDir, error %v", err))
|
panic(fmt.Sprintf("Problem creating TempDir, error %v", err))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"internal/testenv"
|
"internal/testenv"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -223,7 +222,7 @@ func testNexting(t *testing.T, base, tag, gcflags string, count int, moreArgs ..
|
||||||
|
|
||||||
// Use a temporary directory unless -f is specified
|
// Use a temporary directory unless -f is specified
|
||||||
if !*force {
|
if !*force {
|
||||||
tmpdir, err := ioutil.TempDir("", "debug_test")
|
tmpdir, err := os.MkdirTemp("", "debug_test")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Sprintf("Problem creating TempDir, error %v\n", err))
|
panic(fmt.Sprintf("Problem creating TempDir, error %v\n", err))
|
||||||
}
|
}
|
||||||
|
|
@ -366,7 +365,7 @@ func (h *nextHist) write(filename string) {
|
||||||
|
|
||||||
func (h *nextHist) read(filename string) {
|
func (h *nextHist) read(filename string) {
|
||||||
h.f2i = make(map[string]uint8)
|
h.f2i = make(map[string]uint8)
|
||||||
bytes, err := ioutil.ReadFile(filename)
|
bytes, err := os.ReadFile(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Sprintf("Problem reading %s, error %v\n", filename, err))
|
panic(fmt.Sprintf("Problem reading %s, error %v\n", filename, err))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"go/format"
|
"go/format"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
|
@ -500,7 +499,7 @@ func genOp() {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := ioutil.WriteFile("../opGen.go", b, 0666); err != nil {
|
if err := os.WriteFile("../opGen.go", b, 0666); err != nil {
|
||||||
log.Fatalf("can't write output: %v\n", err)
|
log.Fatalf("can't write output: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -521,7 +520,7 @@ func genOp() {
|
||||||
log.Fatalf("bad opcode regexp %s: %v", pattern, err)
|
log.Fatalf("bad opcode regexp %s: %v", pattern, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
src, err := ioutil.ReadFile(a.genfile)
|
src, err := os.ReadFile(a.genfile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("can't read %s: %v", a.genfile, err)
|
log.Fatalf("can't read %s: %v", a.genfile, err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ import (
|
||||||
"go/printer"
|
"go/printer"
|
||||||
"go/token"
|
"go/token"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
|
@ -280,7 +279,7 @@ func genRulesSuffix(arch arch, suff string) {
|
||||||
file, err := parser.ParseFile(fset, "", buf, parser.ParseComments)
|
file, err := parser.ParseFile(fset, "", buf, parser.ParseComments)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
filename := fmt.Sprintf("%s_broken.go", arch.name)
|
filename := fmt.Sprintf("%s_broken.go", arch.name)
|
||||||
if err := ioutil.WriteFile(filename, buf.Bytes(), 0644); err != nil {
|
if err := os.WriteFile(filename, buf.Bytes(), 0644); err != nil {
|
||||||
log.Printf("failed to dump broken code to %s: %v", filename, err)
|
log.Printf("failed to dump broken code to %s: %v", filename, err)
|
||||||
} else {
|
} else {
|
||||||
log.Printf("dumped broken code to %s", filename)
|
log.Printf("dumped broken code to %s", filename)
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ package ssagen
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"internal/buildcfg"
|
"internal/buildcfg"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -59,7 +58,7 @@ func (s *SymABIs) canonicalize(linksym string) string {
|
||||||
// the symbol name and the third field is the ABI name, as one of the
|
// the symbol name and the third field is the ABI name, as one of the
|
||||||
// named cmd/internal/obj.ABI constants.
|
// named cmd/internal/obj.ABI constants.
|
||||||
func (s *SymABIs) ReadSymABIs(file string) {
|
func (s *SymABIs) ReadSymABIs(file string) {
|
||||||
data, err := ioutil.ReadFile(file)
|
data, err := os.ReadFile(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("-symabis: %v", err)
|
log.Fatalf("-symabis: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"go/constant"
|
"go/constant"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
@ -124,7 +123,7 @@ func fileStringSym(pos src.XPos, file string, readonly bool, hash []byte) (*obj.
|
||||||
}
|
}
|
||||||
size := info.Size()
|
size := info.Size()
|
||||||
if size <= 1*1024 {
|
if size <= 1*1024 {
|
||||||
data, err := ioutil.ReadAll(f)
|
data, err := io.ReadAll(f)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"internal/testenv"
|
"internal/testenv"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
|
@ -178,7 +177,7 @@ func testSyntaxErrors(t *testing.T, filename string) {
|
||||||
func TestSyntaxErrors(t *testing.T) {
|
func TestSyntaxErrors(t *testing.T) {
|
||||||
testenv.MustHaveGoBuild(t) // we need access to source (testdata)
|
testenv.MustHaveGoBuild(t) // we need access to source (testdata)
|
||||||
|
|
||||||
list, err := ioutil.ReadDir(testdata)
|
list, err := os.ReadDir(testdata)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"internal/testenv"
|
"internal/testenv"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
@ -112,21 +112,21 @@ func TestStdLib(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func walkDirs(t *testing.T, dir string, action func(string)) {
|
func walkDirs(t *testing.T, dir string, action func(string)) {
|
||||||
fis, err := ioutil.ReadDir(dir)
|
entries, err := os.ReadDir(dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var files, dirs []string
|
var files, dirs []string
|
||||||
for _, fi := range fis {
|
for _, entry := range entries {
|
||||||
if fi.Mode().IsRegular() {
|
if entry.Type().IsRegular() {
|
||||||
if strings.HasSuffix(fi.Name(), ".go") {
|
if strings.HasSuffix(entry.Name(), ".go") {
|
||||||
path := filepath.Join(dir, fi.Name())
|
path := filepath.Join(dir, entry.Name())
|
||||||
files = append(files, path)
|
files = append(files, path)
|
||||||
}
|
}
|
||||||
} else if fi.IsDir() && fi.Name() != "testdata" {
|
} else if entry.IsDir() && entry.Name() != "testdata" {
|
||||||
path := filepath.Join(dir, fi.Name())
|
path := filepath.Join(dir, entry.Name())
|
||||||
if !strings.HasSuffix(path, string(filepath.Separator)+"test") {
|
if !strings.HasSuffix(path, string(filepath.Separator)+"test") {
|
||||||
dirs = append(dirs, path)
|
dirs = append(dirs, path)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ package syntax
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
@ -155,7 +154,7 @@ func testOut() io.Writer {
|
||||||
if testing.Verbose() {
|
if testing.Verbose() {
|
||||||
return os.Stdout
|
return os.Stdout
|
||||||
}
|
}
|
||||||
return ioutil.Discard
|
return io.Discard
|
||||||
}
|
}
|
||||||
|
|
||||||
func dup(s string) [2]string { return [2]string{s, s} }
|
func dup(s string) [2]string { return [2]string{s, s} }
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ package test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"internal/testenv"
|
"internal/testenv"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
@ -39,7 +39,7 @@ func runHello(t *testing.T, flag string) {
|
||||||
|
|
||||||
tmpdir := t.TempDir()
|
tmpdir := t.TempDir()
|
||||||
src := filepath.Join(tmpdir, "x.go")
|
src := filepath.Join(tmpdir, "x.go")
|
||||||
err := ioutil.WriteFile(src, []byte(helloSrc), 0644)
|
err := os.WriteFile(src, []byte(helloSrc), 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("write file failed: %v", err)
|
t.Fatalf("write file failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ package test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"internal/testenv"
|
"internal/testenv"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -60,14 +59,14 @@ func TestIssue15854b(t *testing.T) {
|
||||||
// Test that the generated assembly has line numbers (Issue #16214).
|
// Test that the generated assembly has line numbers (Issue #16214).
|
||||||
func TestIssue16214(t *testing.T) {
|
func TestIssue16214(t *testing.T) {
|
||||||
testenv.MustHaveGoBuild(t)
|
testenv.MustHaveGoBuild(t)
|
||||||
dir, err := ioutil.TempDir("", "TestLineNumber")
|
dir, err := os.MkdirTemp("", "TestLineNumber")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("could not create directory: %v", err)
|
t.Fatalf("could not create directory: %v", err)
|
||||||
}
|
}
|
||||||
defer os.RemoveAll(dir)
|
defer os.RemoveAll(dir)
|
||||||
|
|
||||||
src := filepath.Join(dir, "x.go")
|
src := filepath.Join(dir, "x.go")
|
||||||
err = ioutil.WriteFile(src, []byte(issue16214src), 0644)
|
err = os.WriteFile(src, []byte(issue16214src), 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("could not write file: %v", err)
|
t.Fatalf("could not write file: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ package test
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"internal/testenv"
|
"internal/testenv"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -22,7 +21,7 @@ func TestScanfRemoval(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
// Make a directory to work in.
|
// Make a directory to work in.
|
||||||
dir, err := ioutil.TempDir("", "issue6853a-")
|
dir, err := os.MkdirTemp("", "issue6853a-")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("could not create directory: %v", err)
|
t.Fatalf("could not create directory: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -70,7 +69,7 @@ func TestDashS(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
// Make a directory to work in.
|
// Make a directory to work in.
|
||||||
dir, err := ioutil.TempDir("", "issue14515-")
|
dir, err := os.MkdirTemp("", "issue14515-")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("could not create directory: %v", err)
|
t.Fatalf("could not create directory: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ package test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"internal/testenv"
|
"internal/testenv"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -22,7 +21,7 @@ func TestInst(t *testing.T) {
|
||||||
|
|
||||||
var tmpdir string
|
var tmpdir string
|
||||||
var err error
|
var err error
|
||||||
tmpdir, err = ioutil.TempDir("", "TestDict")
|
tmpdir, err = os.MkdirTemp("", "TestDict")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to create temporary directory: %v", err)
|
t.Fatalf("Failed to create temporary directory: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -59,7 +58,7 @@ func TestInst(t *testing.T) {
|
||||||
if output, err = cmd.CombinedOutput(); err != nil {
|
if output, err = cmd.CombinedOutput(); err != nil {
|
||||||
t.Fatalf("Failed: %v:\nOut: %s\n", err, output)
|
t.Fatalf("Failed: %v:\nOut: %s\n", err, output)
|
||||||
}
|
}
|
||||||
out, err := ioutil.ReadFile(filepath.Join("testdata", outname))
|
out, err := os.ReadFile(filepath.Join("testdata", outname))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Could not find %s\n", outname)
|
t.Fatalf("Could not find %s\n", outname)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ package test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"internal/testenv"
|
"internal/testenv"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -24,14 +23,14 @@ func TestInvalidLang(t *testing.T) {
|
||||||
|
|
||||||
testenv.MustHaveGoBuild(t)
|
testenv.MustHaveGoBuild(t)
|
||||||
|
|
||||||
dir, err := ioutil.TempDir("", "TestInvalidLang")
|
dir, err := os.MkdirTemp("", "TestInvalidLang")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer os.RemoveAll(dir)
|
defer os.RemoveAll(dir)
|
||||||
|
|
||||||
src := filepath.Join(dir, "alias.go")
|
src := filepath.Join(dir, "alias.go")
|
||||||
if err := ioutil.WriteFile(src, []byte(aliasSrc), 0644); err != nil {
|
if err := os.WriteFile(src, []byte(aliasSrc), 0644); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ package test
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"internal/testenv"
|
"internal/testenv"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -32,7 +31,7 @@ func TestReproducibleBuilds(t *testing.T) {
|
||||||
t.Run(test, func(t *testing.T) {
|
t.Run(test, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
var want []byte
|
var want []byte
|
||||||
tmp, err := ioutil.TempFile("", "")
|
tmp, err := os.CreateTemp("", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("temp file creation failed: %v", err)
|
t.Fatalf("temp file creation failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -45,7 +44,7 @@ func TestReproducibleBuilds(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to compile: %v\n%s", err, out)
|
t.Fatalf("failed to compile: %v\n%s", err, out)
|
||||||
}
|
}
|
||||||
obj, err := ioutil.ReadFile(tmp.Name())
|
obj, err := os.ReadFile(tmp.Name())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to read object file: %v", err)
|
t.Fatalf("failed to read object file: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -78,7 +77,7 @@ func TestIssue38068(t *testing.T) {
|
||||||
{tag: "serial", args: "-c=1"},
|
{tag: "serial", args: "-c=1"},
|
||||||
{tag: "concurrent", args: "-c=2"}}
|
{tag: "concurrent", args: "-c=2"}}
|
||||||
|
|
||||||
tmpdir, err := ioutil.TempDir("", "TestIssue38068")
|
tmpdir, err := os.MkdirTemp("", "TestIssue38068")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
@ -97,7 +96,7 @@ func TestIssue38068(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
readBytes := func(fn string) []byte {
|
readBytes := func(fn string) []byte {
|
||||||
payload, err := ioutil.ReadFile(fn)
|
payload, err := os.ReadFile(fn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to read executable '%s': %v", fn, err)
|
t.Fatalf("failed to read executable '%s': %v", fn, err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ import (
|
||||||
"go/parser"
|
"go/parser"
|
||||||
"go/token"
|
"go/token"
|
||||||
"internal/testenv"
|
"internal/testenv"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -35,14 +34,14 @@ func runGenTest(t *testing.T, filename, tmpname string, ev ...string) {
|
||||||
t.Fatalf("Failed: %v:\nOut: %s\nStderr: %s\n", err, &stdout, &stderr)
|
t.Fatalf("Failed: %v:\nOut: %s\nStderr: %s\n", err, &stdout, &stderr)
|
||||||
}
|
}
|
||||||
// Write stdout into a temporary file
|
// Write stdout into a temporary file
|
||||||
tmpdir, ok := ioutil.TempDir("", tmpname)
|
tmpdir, ok := os.MkdirTemp("", tmpname)
|
||||||
if ok != nil {
|
if ok != nil {
|
||||||
t.Fatalf("Failed to create temporary directory")
|
t.Fatalf("Failed to create temporary directory")
|
||||||
}
|
}
|
||||||
defer os.RemoveAll(tmpdir)
|
defer os.RemoveAll(tmpdir)
|
||||||
|
|
||||||
rungo := filepath.Join(tmpdir, "run.go")
|
rungo := filepath.Join(tmpdir, "run.go")
|
||||||
ok = ioutil.WriteFile(rungo, stdout.Bytes(), 0600)
|
ok = os.WriteFile(rungo, stdout.Bytes(), 0600)
|
||||||
if ok != nil {
|
if ok != nil {
|
||||||
t.Fatalf("Failed to create temporary file " + rungo)
|
t.Fatalf("Failed to create temporary file " + rungo)
|
||||||
}
|
}
|
||||||
|
|
@ -81,7 +80,7 @@ func TestCode(t *testing.T) {
|
||||||
gotool := testenv.GoToolPath(t)
|
gotool := testenv.GoToolPath(t)
|
||||||
|
|
||||||
// Make a temporary directory to work in.
|
// Make a temporary directory to work in.
|
||||||
tmpdir, err := ioutil.TempDir("", "TestCode")
|
tmpdir, err := os.MkdirTemp("", "TestCode")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed to create temporary directory: %v", err)
|
t.Fatalf("Failed to create temporary directory: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -94,7 +93,7 @@ func TestCode(t *testing.T) {
|
||||||
usesFloat bool // might use float operations
|
usesFloat bool // might use float operations
|
||||||
}
|
}
|
||||||
var tests []test
|
var tests []test
|
||||||
files, err := ioutil.ReadDir("testdata")
|
files, err := os.ReadDir("testdata")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("can't read testdata directory: %v", err)
|
t.Fatalf("can't read testdata directory: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -102,7 +101,7 @@ func TestCode(t *testing.T) {
|
||||||
if !strings.HasSuffix(f.Name(), "_test.go") {
|
if !strings.HasSuffix(f.Name(), "_test.go") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
text, err := ioutil.ReadFile(filepath.Join("testdata", f.Name()))
|
text, err := os.ReadFile(filepath.Join("testdata", f.Name()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("can't read testdata/%s: %v", f.Name(), err)
|
t.Fatalf("can't read testdata/%s: %v", f.Name(), err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"go/format"
|
"go/format"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"text/template"
|
"text/template"
|
||||||
)
|
)
|
||||||
|
|
@ -202,7 +201,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// write to file
|
// write to file
|
||||||
err = ioutil.WriteFile("../arithBoundary_test.go", src, 0666)
|
err = os.WriteFile("../arithBoundary_test.go", src, 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("can't write output: %v\n", err)
|
log.Fatalf("can't write output: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"go/format"
|
"go/format"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
@ -339,7 +338,7 @@ func TestArithmeticConst(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// write to file
|
// write to file
|
||||||
err = ioutil.WriteFile("../arithConst_test.go", src, 0666)
|
err = os.WriteFile("../arithConst_test.go", src, 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("can't write output: %v\n", err)
|
log.Fatalf("can't write output: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"go/format"
|
"go/format"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"math/big"
|
"math/big"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
@ -240,7 +239,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// write to file
|
// write to file
|
||||||
err = ioutil.WriteFile("../cmpConst_test.go", src, 0666)
|
err = os.WriteFile("../cmpConst_test.go", src, 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("can't write output: %v\n", err)
|
log.Fatalf("can't write output: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"go/format"
|
"go/format"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
type op struct {
|
type op struct {
|
||||||
|
|
@ -300,7 +300,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// write to file
|
// write to file
|
||||||
err = ioutil.WriteFile("../../constFold_test.go", src, 0666)
|
err = os.WriteFile("../../constFold_test.go", src, 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("can't write output: %v\n", err)
|
log.Fatalf("can't write output: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"go/format"
|
"go/format"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
// This program generates tests to verify that copying operations
|
// This program generates tests to verify that copying operations
|
||||||
|
|
@ -114,7 +114,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// write to file
|
// write to file
|
||||||
err = ioutil.WriteFile("../copy_test.go", src, 0666)
|
err = os.WriteFile("../copy_test.go", src, 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("can't write output: %v\n", err)
|
log.Fatalf("can't write output: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"go/format"
|
"go/format"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
// This program generates tests to verify that zeroing operations
|
// This program generates tests to verify that zeroing operations
|
||||||
|
|
@ -136,7 +136,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// write to file
|
// write to file
|
||||||
err = ioutil.WriteFile("../zero_test.go", src, 0666)
|
err = os.WriteFile("../zero_test.go", src, 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("can't write output: %v\n", err)
|
log.Fatalf("can't write output: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ package typecheck
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"internal/testenv"
|
"internal/testenv"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
@ -16,7 +16,7 @@ func TestBuiltin(t *testing.T) {
|
||||||
testenv.MustHaveGoRun(t)
|
testenv.MustHaveGoRun(t)
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
old, err := ioutil.ReadFile("builtin.go")
|
old, err := os.ReadFile("builtin.go")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ import (
|
||||||
"go/parser"
|
"go/parser"
|
||||||
"go/token"
|
"go/token"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -50,7 +49,7 @@ func main() {
|
||||||
if *stdout {
|
if *stdout {
|
||||||
_, err = os.Stdout.Write(out)
|
_, err = os.Stdout.Write(out)
|
||||||
} else {
|
} else {
|
||||||
err = ioutil.WriteFile("builtin.go", out, 0666)
|
err = os.WriteFile("builtin.go", out, 0666)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,12 @@ package types2_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"cmd/compile/internal/syntax"
|
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"cmd/compile/internal/syntax"
|
||||||
. "cmd/compile/internal/types2"
|
. "cmd/compile/internal/types2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -24,7 +24,7 @@ func TestHilbert(t *testing.T) {
|
||||||
// generate source
|
// generate source
|
||||||
src := program(*H, *out)
|
src := program(*H, *out)
|
||||||
if *out != "" {
|
if *out != "" {
|
||||||
ioutil.WriteFile(*out, src, 0666)
|
os.WriteFile(*out, src, 0666)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
7
src/cmd/dist/build.go
vendored
7
src/cmd/dist/build.go
vendored
|
|
@ -9,7 +9,6 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
|
@ -260,7 +259,7 @@ func xinit() {
|
||||||
os.Setenv("GOWORK", "off")
|
os.Setenv("GOWORK", "off")
|
||||||
|
|
||||||
workdir = xworkdir()
|
workdir = xworkdir()
|
||||||
if err := ioutil.WriteFile(pathf("%s/go.mod", workdir), []byte("module bootstrap"), 0666); err != nil {
|
if err := os.WriteFile(pathf("%s/go.mod", workdir), []byte("module bootstrap"), 0666); err != nil {
|
||||||
fatalf("cannot write stub go.mod: %s", err)
|
fatalf("cannot write stub go.mod: %s", err)
|
||||||
}
|
}
|
||||||
xatexit(rmworkdir)
|
xatexit(rmworkdir)
|
||||||
|
|
@ -833,7 +832,7 @@ func runInstall(pkg string, ch chan struct{}) {
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
asmabis := append(asmArgs[:len(asmArgs):len(asmArgs)], "-gensymabis", "-o", symabis)
|
asmabis := append(asmArgs[:len(asmArgs):len(asmArgs)], "-gensymabis", "-o", symabis)
|
||||||
asmabis = append(asmabis, sfiles...)
|
asmabis = append(asmabis, sfiles...)
|
||||||
if err := ioutil.WriteFile(goasmh, nil, 0666); err != nil {
|
if err := os.WriteFile(goasmh, nil, 0666); err != nil {
|
||||||
fatalf("cannot write empty go_asm.h: %s", err)
|
fatalf("cannot write empty go_asm.h: %s", err)
|
||||||
}
|
}
|
||||||
bgrun(&wg, dir, asmabis...)
|
bgrun(&wg, dir, asmabis...)
|
||||||
|
|
@ -853,7 +852,7 @@ func runInstall(pkg string, ch chan struct{}) {
|
||||||
fmt.Fprintf(buf, "packagefile %s=%s\n", dep, packagefile(dep))
|
fmt.Fprintf(buf, "packagefile %s=%s\n", dep, packagefile(dep))
|
||||||
}
|
}
|
||||||
importcfg := pathf("%s/importcfg", workdir)
|
importcfg := pathf("%s/importcfg", workdir)
|
||||||
if err := ioutil.WriteFile(importcfg, buf.Bytes(), 0666); err != nil {
|
if err := os.WriteFile(importcfg, buf.Bytes(), 0666); err != nil {
|
||||||
fatalf("cannot write importcfg file: %v", err)
|
fatalf("cannot write importcfg file: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
7
src/cmd/dist/test.go
vendored
7
src/cmd/dist/test.go
vendored
|
|
@ -8,7 +8,6 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
|
@ -1180,7 +1179,7 @@ func (t *tester) runHostTest(dir, pkg string) error {
|
||||||
GOEXE := strings.TrimSpace(parts[0])
|
GOEXE := strings.TrimSpace(parts[0])
|
||||||
GOTMPDIR := strings.TrimSpace(parts[1])
|
GOTMPDIR := strings.TrimSpace(parts[1])
|
||||||
|
|
||||||
f, err := ioutil.TempFile(GOTMPDIR, "test.test-*"+GOEXE)
|
f, err := os.CreateTemp(GOTMPDIR, "test.test-*"+GOEXE)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -1531,7 +1530,7 @@ var runtest struct {
|
||||||
|
|
||||||
func (t *tester) testDirTest(dt *distTest, shard, shards int) error {
|
func (t *tester) testDirTest(dt *distTest, shard, shards int) error {
|
||||||
runtest.Do(func() {
|
runtest.Do(func() {
|
||||||
f, err := ioutil.TempFile("", "runtest-*.exe") // named exe for Windows, but harmless elsewhere
|
f, err := os.CreateTemp("", "runtest-*.exe") // named exe for Windows, but harmless elsewhere
|
||||||
if err != nil {
|
if err != nil {
|
||||||
runtest.err = err
|
runtest.err = err
|
||||||
return
|
return
|
||||||
|
|
@ -1591,7 +1590,7 @@ func (t *tester) packageHasBenchmarks(pkg string) bool {
|
||||||
if !strings.HasSuffix(name, "_test.go") {
|
if !strings.HasSuffix(name, "_test.go") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
slurp, err := ioutil.ReadFile(filepath.Join(pkgDir, name))
|
slurp, err := os.ReadFile(filepath.Join(pkgDir, name))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return true // conservatively
|
return true // conservatively
|
||||||
}
|
}
|
||||||
|
|
|
||||||
9
src/cmd/dist/util.go
vendored
9
src/cmd/dist/util.go
vendored
|
|
@ -9,7 +9,6 @@ import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -228,7 +227,7 @@ func mtime(p string) time.Time {
|
||||||
|
|
||||||
// readfile returns the content of the named file.
|
// readfile returns the content of the named file.
|
||||||
func readfile(file string) string {
|
func readfile(file string) string {
|
||||||
data, err := ioutil.ReadFile(file)
|
data, err := os.ReadFile(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fatalf("%v", err)
|
fatalf("%v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -247,7 +246,7 @@ const (
|
||||||
func writefile(text, file string, flag int) {
|
func writefile(text, file string, flag int) {
|
||||||
new := []byte(text)
|
new := []byte(text)
|
||||||
if flag&writeSkipSame != 0 {
|
if flag&writeSkipSame != 0 {
|
||||||
old, err := ioutil.ReadFile(file)
|
old, err := os.ReadFile(file)
|
||||||
if err == nil && bytes.Equal(old, new) {
|
if err == nil && bytes.Equal(old, new) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -257,7 +256,7 @@ func writefile(text, file string, flag int) {
|
||||||
mode = 0777
|
mode = 0777
|
||||||
}
|
}
|
||||||
xremove(file) // in case of symlink tricks by misc/reboot test
|
xremove(file) // in case of symlink tricks by misc/reboot test
|
||||||
err := ioutil.WriteFile(file, new, mode)
|
err := os.WriteFile(file, new, mode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fatalf("%v", err)
|
fatalf("%v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -334,7 +333,7 @@ func xreaddirfiles(dir string) []string {
|
||||||
// xworkdir creates a new temporary directory to hold object files
|
// xworkdir creates a new temporary directory to hold object files
|
||||||
// and returns the name of that directory.
|
// and returns the name of that directory.
|
||||||
func xworkdir() string {
|
func xworkdir() string {
|
||||||
name, err := ioutil.TempDir(os.Getenv("GOTMPDIR"), "go-tool-dist-")
|
name, err := os.MkdirTemp(os.Getenv("GOTMPDIR"), "go-tool-dist-")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fatalf("%v", err)
|
fatalf("%v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"internal/godebug"
|
"internal/godebug"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
pathpkg "path"
|
pathpkg "path"
|
||||||
|
|
@ -291,14 +290,11 @@ func parentIsOverlayFile(name string) (string, bool) {
|
||||||
var errNotDir = errors.New("not a directory")
|
var errNotDir = errors.New("not a directory")
|
||||||
|
|
||||||
// readDir reads a dir on disk, returning an error that is errNotDir if the dir is not a directory.
|
// readDir reads a dir on disk, returning an error that is errNotDir if the dir is not a directory.
|
||||||
// Unfortunately, the error returned by ioutil.ReadDir if dir is not a directory
|
// Unfortunately, the error returned by os.ReadDir if dir is not a directory
|
||||||
// can vary depending on the OS (Linux, Mac, Windows return ENOTDIR; BSD returns EINVAL).
|
// can vary depending on the OS (Linux, Mac, Windows return ENOTDIR; BSD returns EINVAL).
|
||||||
func readDir(dir string) ([]fs.FileInfo, error) {
|
func readDir(dir string) ([]fs.FileInfo, error) {
|
||||||
fis, err := ioutil.ReadDir(dir)
|
entries, err := os.ReadDir(dir)
|
||||||
if err == nil {
|
if err != nil {
|
||||||
return fis, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -308,6 +304,17 @@ func readDir(dir string) ([]fs.FileInfo, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fis := make([]fs.FileInfo, 0, len(entries))
|
||||||
|
for _, entry := range entries {
|
||||||
|
info, err := entry.Info()
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
fis = append(fis, info)
|
||||||
|
}
|
||||||
|
return fis, nil
|
||||||
|
}
|
||||||
|
|
||||||
// ReadDir provides a slice of fs.FileInfo entries corresponding
|
// ReadDir provides a slice of fs.FileInfo entries corresponding
|
||||||
// to the overlaid files in the directory.
|
// to the overlaid files in the directory.
|
||||||
func ReadDir(dir string) ([]fs.FileInfo, error) {
|
func ReadDir(dir string) ([]fs.FileInfo, error) {
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"go/build"
|
"go/build"
|
||||||
"internal/lazyregexp"
|
"internal/lazyregexp"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -592,7 +591,7 @@ func loadWorkFile(path string) (goVersion string, modRoots []string, replaces []
|
||||||
|
|
||||||
// ReadWorkFile reads and parses the go.work file at the given path.
|
// ReadWorkFile reads and parses the go.work file at the given path.
|
||||||
func ReadWorkFile(path string) (*modfile.WorkFile, error) {
|
func ReadWorkFile(path string) (*modfile.WorkFile, error) {
|
||||||
workData, err := ioutil.ReadFile(path)
|
workData, err := os.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -606,7 +605,7 @@ func WriteWorkFile(path string, wf *modfile.WorkFile) error {
|
||||||
wf.Cleanup()
|
wf.Cleanup()
|
||||||
out := modfile.Format(wf.Syntax)
|
out := modfile.Format(wf.Syntax)
|
||||||
|
|
||||||
return ioutil.WriteFile(path, out, 0666)
|
return os.WriteFile(path, out, 0666)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateWorkFile updates comments on directory directives in the go.work
|
// UpdateWorkFile updates comments on directory directives in the go.work
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@ import (
|
||||||
"internal/testenv"
|
"internal/testenv"
|
||||||
"internal/xcoff"
|
"internal/xcoff"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -43,12 +42,12 @@ func copyDir(dst, src string) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
fis, err := ioutil.ReadDir(src)
|
entries, err := os.ReadDir(src)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for _, fi := range fis {
|
for _, entry := range entries {
|
||||||
err = copyFile(filepath.Join(dst, fi.Name()), filepath.Join(src, fi.Name()))
|
err = copyFile(filepath.Join(dst, entry.Name()), filepath.Join(src, entry.Name()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -96,7 +95,7 @@ type goobjPaths struct {
|
||||||
func buildGoobj(t *testing.T) goobjPaths {
|
func buildGoobj(t *testing.T) goobjPaths {
|
||||||
buildOnce.Do(func() {
|
buildOnce.Do(func() {
|
||||||
buildErr = func() (err error) {
|
buildErr = func() (err error) {
|
||||||
buildDir, err = ioutil.TempDir("", "TestGoobj")
|
buildDir, err = os.MkdirTemp("", "TestGoobj")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -132,7 +131,7 @@ func buildGoobj(t *testing.T) goobjPaths {
|
||||||
gopath := filepath.Join(buildDir, "gopath")
|
gopath := filepath.Join(buildDir, "gopath")
|
||||||
err = copyDir(filepath.Join(gopath, "src", "mycgo"), filepath.Join("testdata", "mycgo"))
|
err = copyDir(filepath.Join(gopath, "src", "mycgo"), filepath.Join("testdata", "mycgo"))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = ioutil.WriteFile(filepath.Join(gopath, "src", "mycgo", "go.mod"), []byte("module mycgo\n"), 0666)
|
err = os.WriteFile(filepath.Join(gopath, "src", "mycgo", "go.mod"), []byte("module mycgo\n"), 0666)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"internal/obscuretestdata"
|
"internal/obscuretestdata"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -21,7 +20,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestReadFile(t *testing.T) {
|
func TestReadFile(t *testing.T) {
|
||||||
f, err := ioutil.TempFile("", "buildid-test-")
|
f, err := os.CreateTemp("", "buildid-test-")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
@ -59,7 +58,7 @@ func TestReadFile(t *testing.T) {
|
||||||
t.Errorf("ReadFile(%s) [readSize=2k] = %q, %v, want %q, nil", f, id, err, expectedID)
|
t.Errorf("ReadFile(%s) [readSize=2k] = %q, %v, want %q, nil", f, id, err, expectedID)
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := ioutil.ReadFile(f)
|
data, err := os.ReadFile(f)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
@ -68,7 +67,7 @@ func TestReadFile(t *testing.T) {
|
||||||
t.Errorf("FindAndHash(%s): %v", f, err)
|
t.Errorf("FindAndHash(%s): %v", f, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if err := ioutil.WriteFile(tmp, data, 0666); err != nil {
|
if err := os.WriteFile(tmp, data, 0666); err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ import (
|
||||||
"go/parser"
|
"go/parser"
|
||||||
"go/token"
|
"go/token"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -44,7 +43,7 @@ func main() {
|
||||||
if *stdout {
|
if *stdout {
|
||||||
_, err = os.Stdout.Write(out)
|
_, err = os.Stdout.Write(out)
|
||||||
} else {
|
} else {
|
||||||
err = ioutil.WriteFile("builtinlist.go", out, 0666)
|
err = os.WriteFile("builtinlist.go", out, 0666)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
|
|
||||||
|
|
@ -7,15 +7,15 @@ package goobj
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"cmd/internal/bio"
|
|
||||||
"cmd/internal/objabi"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"internal/buildcfg"
|
"internal/buildcfg"
|
||||||
"internal/testenv"
|
"internal/testenv"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"cmd/internal/bio"
|
||||||
|
"cmd/internal/objabi"
|
||||||
)
|
)
|
||||||
|
|
||||||
func dummyWriter(buf *bytes.Buffer) *Writer {
|
func dummyWriter(buf *bytes.Buffer) *Writer {
|
||||||
|
|
@ -97,7 +97,7 @@ func TestIssue41621LargeNumberOfRelocations(t *testing.T) {
|
||||||
}
|
}
|
||||||
testenv.MustHaveGoBuild(t)
|
testenv.MustHaveGoBuild(t)
|
||||||
|
|
||||||
tmpdir, err := ioutil.TempDir("", "lotsofrelocs")
|
tmpdir, err := os.MkdirTemp("", "lotsofrelocs")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("can't create temp directory: %v\n", err)
|
t.Fatalf("can't create temp directory: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
@ -110,7 +110,7 @@ func TestIssue41621LargeNumberOfRelocations(t *testing.T) {
|
||||||
fmt.Fprintf(&w, "\t\"%d\",\n", i)
|
fmt.Fprintf(&w, "\t\"%d\",\n", i)
|
||||||
}
|
}
|
||||||
fmt.Fprintf(&w, issue41621epilog)
|
fmt.Fprintf(&w, issue41621epilog)
|
||||||
err = ioutil.WriteFile(tmpdir+"/large.go", w.Bytes(), 0666)
|
err = os.WriteFile(tmpdir+"/large.go", w.Bytes(), 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("can't write output: %v\n", err)
|
t.Fatalf("can't write output: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
@ -118,7 +118,7 @@ func TestIssue41621LargeNumberOfRelocations(t *testing.T) {
|
||||||
// Emit go.mod
|
// Emit go.mod
|
||||||
w.Reset()
|
w.Reset()
|
||||||
fmt.Fprintf(&w, "module issue41621\n\ngo 1.12\n")
|
fmt.Fprintf(&w, "module issue41621\n\ngo 1.12\n")
|
||||||
err = ioutil.WriteFile(tmpdir+"/go.mod", w.Bytes(), 0666)
|
err = os.WriteFile(tmpdir+"/go.mod", w.Bytes(), 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("can't write output: %v\n", err)
|
t.Fatalf("can't write output: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ import (
|
||||||
"internal/testenv"
|
"internal/testenv"
|
||||||
"io"
|
"io"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -361,7 +360,7 @@ func TestDependencyVersionsConsistent(t *testing.T) {
|
||||||
// It's ok if there are undetected differences in modules that do not
|
// It's ok if there are undetected differences in modules that do not
|
||||||
// provide imported packages: we will not have to pull in any backports of
|
// provide imported packages: we will not have to pull in any backports of
|
||||||
// fixes to those modules anyway.
|
// fixes to those modules anyway.
|
||||||
vendor, err := ioutil.ReadFile(filepath.Join(m.Dir, "vendor", "modules.txt"))
|
vendor, err := os.ReadFile(filepath.Join(m.Dir, "vendor", "modules.txt"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"internal/testenv"
|
"internal/testenv"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -27,7 +26,7 @@ func TestLarge(t *testing.T) {
|
||||||
}
|
}
|
||||||
testenv.MustHaveGoBuild(t)
|
testenv.MustHaveGoBuild(t)
|
||||||
|
|
||||||
dir, err := ioutil.TempDir("", "testlarge")
|
dir, err := os.MkdirTemp("", "testlarge")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("could not create directory: %v", err)
|
t.Fatalf("could not create directory: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -38,7 +37,7 @@ func TestLarge(t *testing.T) {
|
||||||
gen(buf)
|
gen(buf)
|
||||||
|
|
||||||
tmpfile := filepath.Join(dir, "x.s")
|
tmpfile := filepath.Join(dir, "x.s")
|
||||||
err = ioutil.WriteFile(tmpfile, buf.Bytes(), 0644)
|
err = os.WriteFile(tmpfile, buf.Bytes(), 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("can't write output: %v\n", err)
|
t.Fatalf("can't write output: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
@ -86,13 +85,13 @@ func gen(buf *bytes.Buffer) {
|
||||||
|
|
||||||
// Issue 20348.
|
// Issue 20348.
|
||||||
func TestNoRet(t *testing.T) {
|
func TestNoRet(t *testing.T) {
|
||||||
dir, err := ioutil.TempDir("", "testnoret")
|
dir, err := os.MkdirTemp("", "testnoret")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer os.RemoveAll(dir)
|
defer os.RemoveAll(dir)
|
||||||
tmpfile := filepath.Join(dir, "x.s")
|
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)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
cmd := exec.Command(testenv.GoToolPath(t), "tool", "asm", "-o", filepath.Join(dir, "x.o"), tmpfile)
|
cmd := exec.Command(testenv.GoToolPath(t), "tool", "asm", "-o", filepath.Join(dir, "x.o"), tmpfile)
|
||||||
|
|
@ -106,7 +105,7 @@ func TestNoRet(t *testing.T) {
|
||||||
// code can be aligned to the alignment value.
|
// code can be aligned to the alignment value.
|
||||||
func TestPCALIGN(t *testing.T) {
|
func TestPCALIGN(t *testing.T) {
|
||||||
testenv.MustHaveGoBuild(t)
|
testenv.MustHaveGoBuild(t)
|
||||||
dir, err := ioutil.TempDir("", "testpcalign")
|
dir, err := os.MkdirTemp("", "testpcalign")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
@ -130,7 +129,7 @@ func TestPCALIGN(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range testCases {
|
for _, test := range testCases {
|
||||||
if err := ioutil.WriteFile(tmpfile, test.code, 0644); err != nil {
|
if err := os.WriteFile(tmpfile, test.code, 0644); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
cmd := exec.Command(testenv.GoToolPath(t), "tool", "asm", "-S", "-o", tmpout, tmpfile)
|
cmd := exec.Command(testenv.GoToolPath(t), "tool", "asm", "-S", "-o", tmpout, tmpfile)
|
||||||
|
|
|
||||||
|
|
@ -6,15 +6,15 @@ package obj
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"cmd/internal/goobj"
|
|
||||||
"cmd/internal/sys"
|
|
||||||
"internal/testenv"
|
"internal/testenv"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
|
"cmd/internal/goobj"
|
||||||
|
"cmd/internal/sys"
|
||||||
)
|
)
|
||||||
|
|
||||||
var dummyArch = LinkArch{Arch: sys.ArchAMD64}
|
var dummyArch = LinkArch{Arch: sys.ArchAMD64}
|
||||||
|
|
@ -99,14 +99,14 @@ func TestSymbolTooLarge(t *testing.T) { // Issue 42054
|
||||||
t.Skip("skip on 32-bit architectures")
|
t.Skip("skip on 32-bit architectures")
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpdir, err := ioutil.TempDir("", "TestSymbolTooLarge")
|
tmpdir, err := os.MkdirTemp("", "TestSymbolTooLarge")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer os.RemoveAll(tmpdir)
|
defer os.RemoveAll(tmpdir)
|
||||||
|
|
||||||
src := filepath.Join(tmpdir, "p.go")
|
src := filepath.Join(tmpdir, "p.go")
|
||||||
err = ioutil.WriteFile(src, []byte("package p; var x [1<<32]byte"), 0666)
|
err = os.WriteFile(src, []byte("package p; var x [1<<32]byte"), 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to write source file: %v\n", err)
|
t.Fatalf("failed to write source file: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
@ -129,7 +129,7 @@ func TestNoRefName(t *testing.T) {
|
||||||
tmpdir := t.TempDir()
|
tmpdir := t.TempDir()
|
||||||
|
|
||||||
src := filepath.Join(tmpdir, "x.go")
|
src := filepath.Join(tmpdir, "x.go")
|
||||||
err := ioutil.WriteFile(src, []byte("package main; import \"fmt\"; func main() { fmt.Println(123) }\n"), 0666)
|
err := os.WriteFile(src, []byte("package main; import \"fmt\"; func main() { fmt.Println(123) }\n"), 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to write source file: %v\n", err)
|
t.Fatalf("failed to write source file: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,8 @@ package ppc64
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"cmd/internal/obj"
|
|
||||||
"cmd/internal/objabi"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"internal/testenv"
|
"internal/testenv"
|
||||||
"io/ioutil"
|
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
|
@ -18,6 +15,9 @@ import (
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"cmd/internal/obj"
|
||||||
|
"cmd/internal/objabi"
|
||||||
)
|
)
|
||||||
|
|
||||||
var platformEnvs = [][]string{
|
var platformEnvs = [][]string{
|
||||||
|
|
@ -167,7 +167,7 @@ PNOP
|
||||||
func TestPfxAlign(t *testing.T) {
|
func TestPfxAlign(t *testing.T) {
|
||||||
testenv.MustHaveGoBuild(t)
|
testenv.MustHaveGoBuild(t)
|
||||||
|
|
||||||
dir, err := ioutil.TempDir("", "testpfxalign")
|
dir, err := os.MkdirTemp("", "testpfxalign")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("could not create directory: %v", err)
|
t.Fatalf("could not create directory: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -188,7 +188,7 @@ func TestPfxAlign(t *testing.T) {
|
||||||
|
|
||||||
for _, pgm := range pgms {
|
for _, pgm := range pgms {
|
||||||
tmpfile := filepath.Join(dir, "x.s")
|
tmpfile := filepath.Join(dir, "x.s")
|
||||||
err = ioutil.WriteFile(tmpfile, pgm.text, 0644)
|
err = os.WriteFile(tmpfile, pgm.text, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("can't write output: %v\n", err)
|
t.Fatalf("can't write output: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
@ -217,7 +217,7 @@ func TestLarge(t *testing.T) {
|
||||||
}
|
}
|
||||||
testenv.MustHaveGoBuild(t)
|
testenv.MustHaveGoBuild(t)
|
||||||
|
|
||||||
dir, err := ioutil.TempDir("", "testlarge")
|
dir, err := os.MkdirTemp("", "testlarge")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("could not create directory: %v", err)
|
t.Fatalf("could not create directory: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -281,7 +281,7 @@ func TestLarge(t *testing.T) {
|
||||||
gen(buf, test.jmpinsn)
|
gen(buf, test.jmpinsn)
|
||||||
|
|
||||||
tmpfile := filepath.Join(dir, "x.s")
|
tmpfile := filepath.Join(dir, "x.s")
|
||||||
err = ioutil.WriteFile(tmpfile, buf.Bytes(), 0644)
|
err = os.WriteFile(tmpfile, buf.Bytes(), 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("can't write output: %v\n", err)
|
t.Fatalf("can't write output: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
@ -336,7 +336,7 @@ func TestPCalign(t *testing.T) {
|
||||||
|
|
||||||
testenv.MustHaveGoBuild(t)
|
testenv.MustHaveGoBuild(t)
|
||||||
|
|
||||||
dir, err := ioutil.TempDir("", "testpcalign")
|
dir, err := os.MkdirTemp("", "testpcalign")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("could not create directory: %v", err)
|
t.Fatalf("could not create directory: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -345,7 +345,7 @@ func TestPCalign(t *testing.T) {
|
||||||
// generate a test with valid uses of PCALIGN
|
// generate a test with valid uses of PCALIGN
|
||||||
|
|
||||||
tmpfile := filepath.Join(dir, "x.s")
|
tmpfile := filepath.Join(dir, "x.s")
|
||||||
err = ioutil.WriteFile(tmpfile, []byte(validPCAlignSrc), 0644)
|
err = os.WriteFile(tmpfile, []byte(validPCAlignSrc), 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("can't write output: %v\n", err)
|
t.Fatalf("can't write output: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
@ -385,7 +385,7 @@ func TestPCalign(t *testing.T) {
|
||||||
// generate a test with invalid use of PCALIGN
|
// generate a test with invalid use of PCALIGN
|
||||||
|
|
||||||
tmpfile = filepath.Join(dir, "xi.s")
|
tmpfile = filepath.Join(dir, "xi.s")
|
||||||
err = ioutil.WriteFile(tmpfile, []byte(invalidPCAlignSrc), 0644)
|
err = os.WriteFile(tmpfile, []byte(invalidPCAlignSrc), 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("can't write output: %v\n", err)
|
t.Fatalf("can't write output: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"internal/testenv"
|
"internal/testenv"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -24,7 +23,7 @@ func TestLargeBranch(t *testing.T) {
|
||||||
}
|
}
|
||||||
testenv.MustHaveGoBuild(t)
|
testenv.MustHaveGoBuild(t)
|
||||||
|
|
||||||
dir, err := ioutil.TempDir("", "testlargebranch")
|
dir, err := os.MkdirTemp("", "testlargebranch")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Could not create directory: %v", err)
|
t.Fatalf("Could not create directory: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -35,7 +34,7 @@ func TestLargeBranch(t *testing.T) {
|
||||||
genLargeBranch(buf)
|
genLargeBranch(buf)
|
||||||
|
|
||||||
tmpfile := filepath.Join(dir, "x.s")
|
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)
|
t.Fatalf("Failed to write file: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -67,13 +66,13 @@ func TestLargeCall(t *testing.T) {
|
||||||
}
|
}
|
||||||
testenv.MustHaveGoBuild(t)
|
testenv.MustHaveGoBuild(t)
|
||||||
|
|
||||||
dir, err := ioutil.TempDir("", "testlargecall")
|
dir, err := os.MkdirTemp("", "testlargecall")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("could not create directory: %v", err)
|
t.Fatalf("could not create directory: %v", err)
|
||||||
}
|
}
|
||||||
defer os.RemoveAll(dir)
|
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)
|
t.Fatalf("Failed to write file: %v\n", err)
|
||||||
}
|
}
|
||||||
main := `package main
|
main := `package main
|
||||||
|
|
@ -84,7 +83,7 @@ func main() {
|
||||||
func x()
|
func x()
|
||||||
func y()
|
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)
|
t.Fatalf("failed to write main: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -92,7 +91,7 @@ func y()
|
||||||
buf := bytes.NewBuffer(make([]byte, 0, 7000000))
|
buf := bytes.NewBuffer(make([]byte, 0, 7000000))
|
||||||
genLargeCall(buf)
|
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)
|
t.Fatalf("Failed to write file: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -130,13 +129,13 @@ func genLargeCall(buf *bytes.Buffer) {
|
||||||
|
|
||||||
// Issue 20348.
|
// Issue 20348.
|
||||||
func TestNoRet(t *testing.T) {
|
func TestNoRet(t *testing.T) {
|
||||||
dir, err := ioutil.TempDir("", "testnoret")
|
dir, err := os.MkdirTemp("", "testnoret")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer os.RemoveAll(dir)
|
defer os.RemoveAll(dir)
|
||||||
tmpfile := filepath.Join(dir, "x.s")
|
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)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
cmd := exec.Command(testenv.GoToolPath(t), "tool", "asm", "-o", filepath.Join(dir, "x.o"), tmpfile)
|
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) {
|
func TestImmediateSplitting(t *testing.T) {
|
||||||
dir, err := ioutil.TempDir("", "testimmsplit")
|
dir, err := os.MkdirTemp("", "testimmsplit")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
@ -190,7 +189,7 @@ TEXT _stub(SB),$0-0
|
||||||
MOVF F6, 4096(X5)
|
MOVF F6, 4096(X5)
|
||||||
MOVD 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)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
cmd := exec.Command(testenv.GoToolPath(t), "tool", "asm", "-o", filepath.Join(dir, "x.o"), tmpfile)
|
cmd := exec.Command(testenv.GoToolPath(t), "tool", "asm", "-o", filepath.Join(dir, "x.o"), tmpfile)
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"internal/testenv"
|
"internal/testenv"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -81,7 +80,7 @@ func normalize(s string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func asmOutput(t *testing.T, s string) []byte {
|
func asmOutput(t *testing.T, s string) []byte {
|
||||||
tmpdir, err := ioutil.TempDir("", "progedittest")
|
tmpdir, err := os.MkdirTemp("", "progedittest")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"internal/testenv"
|
"internal/testenv"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -33,12 +32,12 @@ func main() {
|
||||||
`
|
`
|
||||||
|
|
||||||
func objdumpOutput(t *testing.T, mname, source string) []byte {
|
func objdumpOutput(t *testing.T, mname, source string) []byte {
|
||||||
tmpdir, err := ioutil.TempDir("", mname)
|
tmpdir, err := os.MkdirTemp("", mname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer os.RemoveAll(tmpdir)
|
defer os.RemoveAll(tmpdir)
|
||||||
err = ioutil.WriteFile(filepath.Join(tmpdir, "go.mod"), []byte(fmt.Sprintf("module %s\n", mname)), 0666)
|
err = os.WriteFile(filepath.Join(tmpdir, "go.mod"), []byte(fmt.Sprintf("module %s\n", mname)), 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"internal/buildcfg"
|
"internal/buildcfg"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
@ -57,7 +56,7 @@ func expandArgs(in []string) (out []string) {
|
||||||
out = make([]string, 0, len(in)*2)
|
out = make([]string, 0, len(in)*2)
|
||||||
out = append(out, in[:i]...)
|
out = append(out, in[:i]...)
|
||||||
}
|
}
|
||||||
slurp, err := ioutil.ReadFile(s[1:])
|
slurp, err := os.ReadFile(s[1:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,13 +7,11 @@ package objfile
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"cmd/internal/src"
|
|
||||||
"container/list"
|
"container/list"
|
||||||
"debug/gosym"
|
"debug/gosym"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
|
@ -21,6 +19,8 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"text/tabwriter"
|
"text/tabwriter"
|
||||||
|
|
||||||
|
"cmd/internal/src"
|
||||||
|
|
||||||
"golang.org/x/arch/arm/armasm"
|
"golang.org/x/arch/arm/armasm"
|
||||||
"golang.org/x/arch/arm64/arm64asm"
|
"golang.org/x/arch/arm64/arm64asm"
|
||||||
"golang.org/x/arch/ppc64/ppc64asm"
|
"golang.org/x/arch/ppc64/ppc64asm"
|
||||||
|
|
@ -157,7 +157,7 @@ func (fc *FileCache) Line(filename string, line int) ([]byte, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if e == nil {
|
if e == nil {
|
||||||
content, err := ioutil.ReadFile(filename)
|
content, err := os.ReadFile(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -19,7 +18,7 @@ import (
|
||||||
// ToSymbolFunc returns a function that may be used to convert a
|
// ToSymbolFunc returns a function that may be used to convert a
|
||||||
// package path into a string suitable for use as a symbol.
|
// package path into a string suitable for use as a symbol.
|
||||||
// cmd is the gccgo/GoLLVM compiler in use, and tmpdir is a temporary
|
// cmd is the gccgo/GoLLVM compiler in use, and tmpdir is a temporary
|
||||||
// directory to pass to ioutil.TempFile.
|
// directory to pass to os.CreateTemp().
|
||||||
// For example, this returns a function that converts "net/http"
|
// For example, this returns a function that converts "net/http"
|
||||||
// into a string like "net..z2fhttp". The actual string varies for
|
// into a string like "net..z2fhttp". The actual string varies for
|
||||||
// different gccgo/GoLLVM versions, which is why this returns a function
|
// different gccgo/GoLLVM versions, which is why this returns a function
|
||||||
|
|
@ -32,7 +31,7 @@ func ToSymbolFunc(cmd, tmpdir string) (func(string) string, error) {
|
||||||
// the same string. More recent versions use a new mangler
|
// the same string. More recent versions use a new mangler
|
||||||
// that avoids these collisions.
|
// that avoids these collisions.
|
||||||
const filepat = "*_gccgo_manglechck.go"
|
const filepat = "*_gccgo_manglechck.go"
|
||||||
f, err := ioutil.TempFile(tmpdir, filepat)
|
f, err := os.CreateTemp(tmpdir, filepat)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -40,7 +39,7 @@ func ToSymbolFunc(cmd, tmpdir string) (func(string) string, error) {
|
||||||
f.Close()
|
f.Close()
|
||||||
defer os.Remove(gofilename)
|
defer os.Remove(gofilename)
|
||||||
|
|
||||||
if err := ioutil.WriteFile(gofilename, []byte(mangleCheckCode), 0644); err != nil {
|
if err := os.WriteFile(gofilename, []byte(mangleCheckCode), 0644); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -28,7 +28,7 @@ func TestGolden(t *testing.T) {
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
name := strings.TrimSuffix(filepath.Base(file), ".test")
|
name := strings.TrimSuffix(filepath.Base(file), ".test")
|
||||||
t.Run(name, func(t *testing.T) {
|
t.Run(name, func(t *testing.T) {
|
||||||
orig, err := ioutil.ReadFile(file)
|
orig, err := os.ReadFile(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
@ -46,13 +46,13 @@ func TestGolden(t *testing.T) {
|
||||||
if *update {
|
if *update {
|
||||||
js := strings.TrimSuffix(file, ".test") + ".json"
|
js := strings.TrimSuffix(file, ".test") + ".json"
|
||||||
t.Logf("rewriting %s", js)
|
t.Logf("rewriting %s", js)
|
||||||
if err := ioutil.WriteFile(js, buf.Bytes(), 0666); err != nil {
|
if err := os.WriteFile(js, buf.Bytes(), 0666); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
want, err := ioutil.ReadFile(strings.TrimSuffix(file, ".test") + ".json")
|
want, err := os.ReadFile(strings.TrimSuffix(file, ".test") + ".json")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,9 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"cmd/internal/sys"
|
|
||||||
"debug/elf"
|
"debug/elf"
|
||||||
"fmt"
|
"fmt"
|
||||||
"internal/testenv"
|
"internal/testenv"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -21,6 +19,8 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
|
"cmd/internal/sys"
|
||||||
)
|
)
|
||||||
|
|
||||||
func getCCAndCCFLAGS(t *testing.T, env []string) (string, []string) {
|
func getCCAndCCFLAGS(t *testing.T, env []string) (string, []string) {
|
||||||
|
|
@ -75,12 +75,12 @@ func TestSectionsWithSameName(t *testing.T) {
|
||||||
gopath := filepath.Join(dir, "GOPATH")
|
gopath := filepath.Join(dir, "GOPATH")
|
||||||
env := append(os.Environ(), "GOPATH="+gopath)
|
env := append(os.Environ(), "GOPATH="+gopath)
|
||||||
|
|
||||||
if err := ioutil.WriteFile(filepath.Join(dir, "go.mod"), []byte("module elf_test\n"), 0666); err != nil {
|
if err := os.WriteFile(filepath.Join(dir, "go.mod"), []byte("module elf_test\n"), 0666); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
asmFile := filepath.Join(dir, "x.s")
|
asmFile := filepath.Join(dir, "x.s")
|
||||||
if err := ioutil.WriteFile(asmFile, []byte(asmSource), 0444); err != nil {
|
if err := os.WriteFile(asmFile, []byte(asmSource), 0444); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -108,7 +108,7 @@ func TestSectionsWithSameName(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
goFile := filepath.Join(dir, "main.go")
|
goFile := filepath.Join(dir, "main.go")
|
||||||
if err := ioutil.WriteFile(goFile, []byte(goSource), 0444); err != nil {
|
if err := os.WriteFile(goFile, []byte(goSource), 0444); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -145,7 +145,7 @@ func TestMinusRSymsWithSameName(t *testing.T) {
|
||||||
gopath := filepath.Join(dir, "GOPATH")
|
gopath := filepath.Join(dir, "GOPATH")
|
||||||
env := append(os.Environ(), "GOPATH="+gopath)
|
env := append(os.Environ(), "GOPATH="+gopath)
|
||||||
|
|
||||||
if err := ioutil.WriteFile(filepath.Join(dir, "go.mod"), []byte("module elf_test\n"), 0666); err != nil {
|
if err := os.WriteFile(filepath.Join(dir, "go.mod"), []byte("module elf_test\n"), 0666); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -157,7 +157,7 @@ func TestMinusRSymsWithSameName(t *testing.T) {
|
||||||
for i, content := range cSources35779 {
|
for i, content := range cSources35779 {
|
||||||
csrcFile := filepath.Join(dir, fmt.Sprintf("x%d.c", i))
|
csrcFile := filepath.Join(dir, fmt.Sprintf("x%d.c", i))
|
||||||
csrcs = append(csrcs, csrcFile)
|
csrcs = append(csrcs, csrcFile)
|
||||||
if err := ioutil.WriteFile(csrcFile, []byte(content), 0444); err != nil {
|
if err := os.WriteFile(csrcFile, []byte(content), 0444); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -187,7 +187,7 @@ func TestMinusRSymsWithSameName(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
goFile := filepath.Join(dir, "main.go")
|
goFile := filepath.Join(dir, "main.go")
|
||||||
if err := ioutil.WriteFile(goFile, []byte(goSource), 0444); err != nil {
|
if err := os.WriteFile(goFile, []byte(goSource), 0444); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -216,7 +216,7 @@ func TestMergeNoteSections(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
goFile := filepath.Join(t.TempDir(), "notes.go")
|
goFile := filepath.Join(t.TempDir(), "notes.go")
|
||||||
if err := ioutil.WriteFile(goFile, []byte(goSource), 0444); err != nil {
|
if err := os.WriteFile(goFile, []byte(goSource), 0444); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
outFile := filepath.Join(t.TempDir(), "notes.exe")
|
outFile := filepath.Join(t.TempDir(), "notes.exe")
|
||||||
|
|
|
||||||
|
|
@ -5,15 +5,11 @@
|
||||||
package ld
|
package ld
|
||||||
|
|
||||||
import (
|
import (
|
||||||
intdwarf "cmd/internal/dwarf"
|
|
||||||
objfilepkg "cmd/internal/objfile" // renamed to avoid conflict with objfile function
|
|
||||||
"cmd/link/internal/dwtest"
|
|
||||||
"debug/dwarf"
|
"debug/dwarf"
|
||||||
"debug/pe"
|
"debug/pe"
|
||||||
"fmt"
|
"fmt"
|
||||||
"internal/testenv"
|
"internal/testenv"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -23,6 +19,10 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
intdwarf "cmd/internal/dwarf"
|
||||||
|
objfilepkg "cmd/internal/objfile" // renamed to avoid conflict with objfile function
|
||||||
|
"cmd/link/internal/dwtest"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
@ -96,7 +96,7 @@ func gobuild(t *testing.T, dir string, testfile string, gcflags string) *builtFi
|
||||||
src := filepath.Join(dir, "test.go")
|
src := filepath.Join(dir, "test.go")
|
||||||
dst := filepath.Join(dir, "out.exe")
|
dst := filepath.Join(dir, "out.exe")
|
||||||
|
|
||||||
if err := ioutil.WriteFile(src, []byte(testfile), 0666); err != nil {
|
if err := os.WriteFile(src, []byte(testfile), 0666); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1394,7 +1394,7 @@ func TestIssue42484(t *testing.T) {
|
||||||
|
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
tmpdir, err := ioutil.TempDir("", "TestIssue42484")
|
tmpdir, err := os.MkdirTemp("", "TestIssue42484")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("could not create directory: %v", err)
|
t.Fatalf("could not create directory: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ package ld
|
||||||
import (
|
import (
|
||||||
"debug/elf"
|
"debug/elf"
|
||||||
"internal/testenv"
|
"internal/testenv"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -34,7 +33,7 @@ func main() {
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
src := filepath.Join(dir, "issue33358.go")
|
src := filepath.Join(dir, "issue33358.go")
|
||||||
if err := ioutil.WriteFile(src, []byte(prog), 0666); err != nil {
|
if err := os.WriteFile(src, []byte(prog), 0666); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,14 +5,15 @@
|
||||||
package ld
|
package ld
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"cmd/internal/objabi"
|
|
||||||
"internal/testenv"
|
"internal/testenv"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
"runtime"
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"cmd/internal/objabi"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDedupLibraries(t *testing.T) {
|
func TestDedupLibraries(t *testing.T) {
|
||||||
|
|
@ -99,7 +100,7 @@ import (
|
||||||
//go:cgo_import_dynamic _ _ "libc.so"
|
//go:cgo_import_dynamic _ _ "libc.so"
|
||||||
|
|
||||||
func main() {}`
|
func main() {}`
|
||||||
if err := ioutil.WriteFile(srcFile, []byte(src), 0644); err != nil {
|
if err := os.WriteFile(srcFile, []byte(src), 0644); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,22 +32,22 @@
|
||||||
package ld
|
package ld
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"cmd/internal/goobj"
|
|
||||||
"cmd/link/internal/loader"
|
|
||||||
"cmd/link/internal/sym"
|
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"cmd/internal/goobj"
|
||||||
|
"cmd/link/internal/loader"
|
||||||
|
"cmd/link/internal/sym"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (ctxt *Link) readImportCfg(file string) {
|
func (ctxt *Link) readImportCfg(file string) {
|
||||||
ctxt.PackageFile = make(map[string]string)
|
ctxt.PackageFile = make(map[string]string)
|
||||||
ctxt.PackageShlib = make(map[string]string)
|
ctxt.PackageShlib = make(map[string]string)
|
||||||
data, err := ioutil.ReadFile(file)
|
data, err := os.ReadFile(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("-importcfg: %v", err)
|
log.Fatalf("-importcfg: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -196,7 +196,7 @@ func addlibpath(ctxt *Link, srcref, objref, file, pkg, shlib string, fingerprint
|
||||||
l.Fingerprint = fingerprint
|
l.Fingerprint = fingerprint
|
||||||
if shlib != "" {
|
if shlib != "" {
|
||||||
if strings.HasSuffix(shlib, ".shlibname") {
|
if strings.HasSuffix(shlib, ".shlibname") {
|
||||||
data, err := ioutil.ReadFile(shlib)
|
data, err := os.ReadFile(shlib)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Errorf(nil, "cannot read %s: %v", shlib, err)
|
Errorf(nil, "cannot read %s: %v", shlib, err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"debug/pe"
|
"debug/pe"
|
||||||
"fmt"
|
"fmt"
|
||||||
"internal/testenv"
|
"internal/testenv"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
@ -107,7 +107,7 @@ func TestArchiveBuildInvokeWithExec(t *testing.T) {
|
||||||
|
|
||||||
srcfile := filepath.Join(dir, "test.go")
|
srcfile := filepath.Join(dir, "test.go")
|
||||||
arfile := filepath.Join(dir, "test.a")
|
arfile := filepath.Join(dir, "test.a")
|
||||||
if err := ioutil.WriteFile(srcfile, []byte(carchiveSrcText), 0666); err != nil {
|
if err := os.WriteFile(srcfile, []byte(carchiveSrcText), 0666); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -202,7 +202,7 @@ func testWindowsBuildmodeCSharedASLR(t *testing.T, useASLR bool) {
|
||||||
|
|
||||||
srcfile := filepath.Join(dir, "test.go")
|
srcfile := filepath.Join(dir, "test.go")
|
||||||
objfile := filepath.Join(dir, "test.dll")
|
objfile := filepath.Join(dir, "test.dll")
|
||||||
if err := ioutil.WriteFile(srcfile, []byte(`package main; func main() { print("hello") }`), 0666); err != nil {
|
if err := os.WriteFile(srcfile, []byte(`package main; func main() { print("hello") }`), 0666); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
argv := []string{"build", "-buildmode=c-shared"}
|
argv := []string{"build", "-buildmode=c-shared"}
|
||||||
|
|
@ -327,7 +327,7 @@ func main() {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
tempDir := t.TempDir()
|
tempDir := t.TempDir()
|
||||||
src := filepath.Join(tempDir, "x.go")
|
src := filepath.Join(tempDir, "x.go")
|
||||||
if err := ioutil.WriteFile(src, []byte(tt.prog), 0644); err != nil {
|
if err := os.WriteFile(src, []byte(tt.prog), 0644); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
cmd := exec.Command(testenv.GoToolPath(t), "run", src)
|
cmd := exec.Command(testenv.GoToolPath(t), "run", src)
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,21 @@ package ld
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"debug/elf"
|
||||||
|
"debug/macho"
|
||||||
|
"encoding/base64"
|
||||||
|
"encoding/binary"
|
||||||
|
"fmt"
|
||||||
|
"internal/buildcfg"
|
||||||
|
"io"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"cmd/internal/bio"
|
"cmd/internal/bio"
|
||||||
"cmd/internal/goobj"
|
"cmd/internal/goobj"
|
||||||
"cmd/internal/notsha256"
|
"cmd/internal/notsha256"
|
||||||
|
|
@ -43,21 +58,6 @@ import (
|
||||||
"cmd/link/internal/loadpe"
|
"cmd/link/internal/loadpe"
|
||||||
"cmd/link/internal/loadxcoff"
|
"cmd/link/internal/loadxcoff"
|
||||||
"cmd/link/internal/sym"
|
"cmd/link/internal/sym"
|
||||||
"debug/elf"
|
|
||||||
"debug/macho"
|
|
||||||
"encoding/base64"
|
|
||||||
"encoding/binary"
|
|
||||||
"fmt"
|
|
||||||
"internal/buildcfg"
|
|
||||||
"io"
|
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
|
||||||
"os"
|
|
||||||
"os/exec"
|
|
||||||
"path/filepath"
|
|
||||||
"runtime"
|
|
||||||
"strings"
|
|
||||||
"sync"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Data layout and relocation.
|
// Data layout and relocation.
|
||||||
|
|
@ -1157,7 +1157,7 @@ func hostlinksetup(ctxt *Link) {
|
||||||
|
|
||||||
// create temporary directory and arrange cleanup
|
// create temporary directory and arrange cleanup
|
||||||
if *flagTmpdir == "" {
|
if *flagTmpdir == "" {
|
||||||
dir, err := ioutil.TempDir("", "go-link-")
|
dir, err := os.MkdirTemp("", "go-link-")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
@ -1238,7 +1238,7 @@ func writeGDBLinkerScript() string {
|
||||||
}
|
}
|
||||||
INSERT AFTER .debug_types;
|
INSERT AFTER .debug_types;
|
||||||
`
|
`
|
||||||
err := ioutil.WriteFile(path, []byte(src), 0666)
|
err := os.WriteFile(path, []byte(src), 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Errorf(nil, "WriteFile %s failed: %v", name, err)
|
Errorf(nil, "WriteFile %s failed: %v", name, err)
|
||||||
}
|
}
|
||||||
|
|
@ -1849,7 +1849,7 @@ var createTrivialCOnce sync.Once
|
||||||
func linkerFlagSupported(arch *sys.Arch, linker, altLinker, flag string) bool {
|
func linkerFlagSupported(arch *sys.Arch, linker, altLinker, flag string) bool {
|
||||||
createTrivialCOnce.Do(func() {
|
createTrivialCOnce.Do(func() {
|
||||||
src := filepath.Join(*flagTmpdir, "trivial.c")
|
src := filepath.Join(*flagTmpdir, "trivial.c")
|
||||||
if err := ioutil.WriteFile(src, []byte("int main() { return 0; }"), 0666); err != nil {
|
if err := os.WriteFile(src, []byte("int main() { return 0; }"), 0666); err != nil {
|
||||||
Errorf(nil, "WriteFile trivial.c failed: %v", err)
|
Errorf(nil, "WriteFile trivial.c failed: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -6,17 +6,18 @@ package ld
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"cmd/internal/objabi"
|
|
||||||
"cmd/link/internal/loader"
|
|
||||||
"cmd/link/internal/sym"
|
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"math/bits"
|
"math/bits"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"cmd/internal/objabi"
|
||||||
|
"cmd/link/internal/loader"
|
||||||
|
"cmd/link/internal/sym"
|
||||||
)
|
)
|
||||||
|
|
||||||
// This file handles all algorithms related to XCOFF files generation.
|
// This file handles all algorithms related to XCOFF files generation.
|
||||||
|
|
@ -1805,7 +1806,7 @@ func xcoffCreateExportFile(ctxt *Link) (fname string) {
|
||||||
buf.Write([]byte(name + "\n"))
|
buf.Write([]byte(name + "\n"))
|
||||||
}
|
}
|
||||||
|
|
||||||
err := ioutil.WriteFile(fname, buf.Bytes(), 0666)
|
err := os.WriteFile(fname, buf.Bytes(), 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Errorf(nil, "WriteFile %s failed: %v", fname, err)
|
Errorf(nil, "WriteFile %s failed: %v", fname, err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,9 @@ package main
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"cmd/internal/sys"
|
|
||||||
"debug/macho"
|
"debug/macho"
|
||||||
"internal/buildcfg"
|
"internal/buildcfg"
|
||||||
"internal/testenv"
|
"internal/testenv"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -19,6 +17,8 @@ import (
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"cmd/internal/sys"
|
||||||
)
|
)
|
||||||
|
|
||||||
var AuthorPaidByTheColumnInch struct {
|
var AuthorPaidByTheColumnInch struct {
|
||||||
|
|
@ -51,7 +51,7 @@ func main() {}
|
||||||
|
|
||||||
tmpdir := t.TempDir()
|
tmpdir := t.TempDir()
|
||||||
|
|
||||||
err := ioutil.WriteFile(filepath.Join(tmpdir, "main.go"), []byte(source), 0666)
|
err := os.WriteFile(filepath.Join(tmpdir, "main.go"), []byte(source), 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to write main.go: %v\n", err)
|
t.Fatalf("failed to write main.go: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
@ -83,7 +83,7 @@ func TestIssue28429(t *testing.T) {
|
||||||
tmpdir := t.TempDir()
|
tmpdir := t.TempDir()
|
||||||
|
|
||||||
write := func(name, content string) {
|
write := func(name, content string) {
|
||||||
err := ioutil.WriteFile(filepath.Join(tmpdir, name), []byte(content), 0666)
|
err := os.WriteFile(filepath.Join(tmpdir, name), []byte(content), 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
@ -122,7 +122,7 @@ func TestUnresolved(t *testing.T) {
|
||||||
tmpdir := t.TempDir()
|
tmpdir := t.TempDir()
|
||||||
|
|
||||||
write := func(name, content string) {
|
write := func(name, content string) {
|
||||||
err := ioutil.WriteFile(filepath.Join(tmpdir, name), []byte(content), 0666)
|
err := os.WriteFile(filepath.Join(tmpdir, name), []byte(content), 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
@ -190,7 +190,7 @@ func TestIssue33979(t *testing.T) {
|
||||||
tmpdir := t.TempDir()
|
tmpdir := t.TempDir()
|
||||||
|
|
||||||
write := func(name, content string) {
|
write := func(name, content string) {
|
||||||
err := ioutil.WriteFile(filepath.Join(tmpdir, name), []byte(content), 0666)
|
err := os.WriteFile(filepath.Join(tmpdir, name), []byte(content), 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
@ -328,7 +328,7 @@ func TestXFlag(t *testing.T) {
|
||||||
tmpdir := t.TempDir()
|
tmpdir := t.TempDir()
|
||||||
|
|
||||||
src := filepath.Join(tmpdir, "main.go")
|
src := filepath.Join(tmpdir, "main.go")
|
||||||
err := ioutil.WriteFile(src, []byte(testXFlagSrc), 0666)
|
err := os.WriteFile(src, []byte(testXFlagSrc), 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
@ -352,7 +352,7 @@ func TestMachOBuildVersion(t *testing.T) {
|
||||||
tmpdir := t.TempDir()
|
tmpdir := t.TempDir()
|
||||||
|
|
||||||
src := filepath.Join(tmpdir, "main.go")
|
src := filepath.Join(tmpdir, "main.go")
|
||||||
err := ioutil.WriteFile(src, []byte(testMachOBuildVersionSrc), 0666)
|
err := os.WriteFile(src, []byte(testMachOBuildVersionSrc), 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
@ -428,7 +428,7 @@ func TestIssue34788Android386TLSSequence(t *testing.T) {
|
||||||
tmpdir := t.TempDir()
|
tmpdir := t.TempDir()
|
||||||
|
|
||||||
src := filepath.Join(tmpdir, "blah.go")
|
src := filepath.Join(tmpdir, "blah.go")
|
||||||
err := ioutil.WriteFile(src, []byte(Issue34788src), 0666)
|
err := os.WriteFile(src, []byte(Issue34788src), 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
@ -504,19 +504,19 @@ func TestStrictDup(t *testing.T) {
|
||||||
tmpdir := t.TempDir()
|
tmpdir := t.TempDir()
|
||||||
|
|
||||||
src := filepath.Join(tmpdir, "x.go")
|
src := filepath.Join(tmpdir, "x.go")
|
||||||
err := ioutil.WriteFile(src, []byte(testStrictDupGoSrc), 0666)
|
err := os.WriteFile(src, []byte(testStrictDupGoSrc), 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
for _, af := range asmfiles {
|
for _, af := range asmfiles {
|
||||||
src = filepath.Join(tmpdir, af.fname+".s")
|
src = filepath.Join(tmpdir, af.fname+".s")
|
||||||
err = ioutil.WriteFile(src, []byte(af.payload), 0666)
|
err = os.WriteFile(src, []byte(af.payload), 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
src = filepath.Join(tmpdir, "go.mod")
|
src = filepath.Join(tmpdir, "go.mod")
|
||||||
err = ioutil.WriteFile(src, []byte("module teststrictdup\n"), 0666)
|
err = os.WriteFile(src, []byte("module teststrictdup\n"), 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
@ -589,17 +589,17 @@ func TestFuncAlign(t *testing.T) {
|
||||||
tmpdir := t.TempDir()
|
tmpdir := t.TempDir()
|
||||||
|
|
||||||
src := filepath.Join(tmpdir, "go.mod")
|
src := filepath.Join(tmpdir, "go.mod")
|
||||||
err := ioutil.WriteFile(src, []byte("module cmd/link/TestFuncAlign/falign"), 0666)
|
err := os.WriteFile(src, []byte("module cmd/link/TestFuncAlign/falign"), 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
src = filepath.Join(tmpdir, "falign.go")
|
src = filepath.Join(tmpdir, "falign.go")
|
||||||
err = ioutil.WriteFile(src, []byte(testFuncAlignSrc), 0666)
|
err = os.WriteFile(src, []byte(testFuncAlignSrc), 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
src = filepath.Join(tmpdir, "falign.s")
|
src = filepath.Join(tmpdir, "falign.s")
|
||||||
err = ioutil.WriteFile(src, []byte(testFuncAlignAsmSrc), 0666)
|
err = os.WriteFile(src, []byte(testFuncAlignAsmSrc), 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
@ -662,7 +662,7 @@ func TestTrampoline(t *testing.T) {
|
||||||
tmpdir := t.TempDir()
|
tmpdir := t.TempDir()
|
||||||
|
|
||||||
src := filepath.Join(tmpdir, "hello.go")
|
src := filepath.Join(tmpdir, "hello.go")
|
||||||
err := ioutil.WriteFile(src, []byte(testTrampSrc), 0666)
|
err := os.WriteFile(src, []byte(testTrampSrc), 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
@ -720,7 +720,7 @@ func TestTrampolineCgo(t *testing.T) {
|
||||||
tmpdir := t.TempDir()
|
tmpdir := t.TempDir()
|
||||||
|
|
||||||
src := filepath.Join(tmpdir, "hello.go")
|
src := filepath.Join(tmpdir, "hello.go")
|
||||||
err := ioutil.WriteFile(src, []byte(testTrampCgoSrc), 0666)
|
err := os.WriteFile(src, []byte(testTrampCgoSrc), 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
@ -842,7 +842,7 @@ func TestPErsrcBinutils(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that the binary contains the rsrc data
|
// Check that the binary contains the rsrc data
|
||||||
b, err := ioutil.ReadFile(exe)
|
b, err := os.ReadFile(exe)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("reading output failed: %v", err)
|
t.Fatalf("reading output failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -874,7 +874,7 @@ func TestPErsrcLLVM(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that the binary contains the rsrc data
|
// Check that the binary contains the rsrc data
|
||||||
b, err := ioutil.ReadFile(exe)
|
b, err := os.ReadFile(exe)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("reading output failed: %v", err)
|
t.Fatalf("reading output failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -935,7 +935,7 @@ func TestIssue38554(t *testing.T) {
|
||||||
tmpdir := t.TempDir()
|
tmpdir := t.TempDir()
|
||||||
|
|
||||||
src := filepath.Join(tmpdir, "x.go")
|
src := filepath.Join(tmpdir, "x.go")
|
||||||
err := ioutil.WriteFile(src, []byte(testIssue38554Src), 0666)
|
err := os.WriteFile(src, []byte(testIssue38554Src), 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to write source file: %v", err)
|
t.Fatalf("failed to write source file: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -985,7 +985,7 @@ func TestIssue42396(t *testing.T) {
|
||||||
tmpdir := t.TempDir()
|
tmpdir := t.TempDir()
|
||||||
|
|
||||||
src := filepath.Join(tmpdir, "main.go")
|
src := filepath.Join(tmpdir, "main.go")
|
||||||
err := ioutil.WriteFile(src, []byte(testIssue42396src), 0666)
|
err := os.WriteFile(src, []byte(testIssue42396src), 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to write source file: %v", err)
|
t.Fatalf("failed to write source file: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -1056,7 +1056,7 @@ func TestLargeReloc(t *testing.T) {
|
||||||
tmpdir := t.TempDir()
|
tmpdir := t.TempDir()
|
||||||
|
|
||||||
src := filepath.Join(tmpdir, "x.go")
|
src := filepath.Join(tmpdir, "x.go")
|
||||||
err := ioutil.WriteFile(src, []byte(testLargeRelocSrc), 0666)
|
err := os.WriteFile(src, []byte(testLargeRelocSrc), 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to write source file: %v", err)
|
t.Fatalf("failed to write source file: %v", err)
|
||||||
}
|
}
|
||||||
|
|
@ -1091,11 +1091,11 @@ func TestUnlinkableObj(t *testing.T) {
|
||||||
xObj := filepath.Join(tmpdir, "x.o")
|
xObj := filepath.Join(tmpdir, "x.o")
|
||||||
pObj := filepath.Join(tmpdir, "p.o")
|
pObj := filepath.Join(tmpdir, "p.o")
|
||||||
exe := filepath.Join(tmpdir, "x.exe")
|
exe := filepath.Join(tmpdir, "x.exe")
|
||||||
err := ioutil.WriteFile(xSrc, []byte("package main\nimport _ \"p\"\nfunc main() {}\n"), 0666)
|
err := os.WriteFile(xSrc, []byte("package main\nimport _ \"p\"\nfunc main() {}\n"), 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to write source file: %v", err)
|
t.Fatalf("failed to write source file: %v", err)
|
||||||
}
|
}
|
||||||
err = ioutil.WriteFile(pSrc, []byte("package p\n"), 0666)
|
err = os.WriteFile(pSrc, []byte("package p\n"), 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("failed to write source file: %v", err)
|
t.Fatalf("failed to write source file: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"internal/buildcfg"
|
"internal/buildcfg"
|
||||||
"internal/testenv"
|
"internal/testenv"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
@ -28,7 +28,7 @@ func TestLargeText(t *testing.T) {
|
||||||
const FN = 4
|
const FN = 4
|
||||||
tmpdir := t.TempDir()
|
tmpdir := t.TempDir()
|
||||||
|
|
||||||
if err := ioutil.WriteFile(tmpdir+"/go.mod", []byte("module big_test\n"), 0666); err != nil {
|
if err := os.WriteFile(tmpdir+"/go.mod", []byte("module big_test\n"), 0666); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -50,7 +50,7 @@ func TestLargeText(t *testing.T) {
|
||||||
fmt.Fprintf(&w, inst)
|
fmt.Fprintf(&w, inst)
|
||||||
}
|
}
|
||||||
fmt.Fprintf(&w, "\tRET\n")
|
fmt.Fprintf(&w, "\tRET\n")
|
||||||
err := ioutil.WriteFile(tmpdir+"/"+testname+".s", w.Bytes(), 0666)
|
err := os.WriteFile(tmpdir+"/"+testname+".s", w.Bytes(), 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("can't write output: %v\n", err)
|
t.Fatalf("can't write output: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
@ -77,7 +77,7 @@ func TestLargeText(t *testing.T) {
|
||||||
fmt.Fprintf(&w, "\t}\n")
|
fmt.Fprintf(&w, "\t}\n")
|
||||||
fmt.Fprintf(&w, "\tfmt.Printf(\"PASS\\n\")\n")
|
fmt.Fprintf(&w, "\tfmt.Printf(\"PASS\\n\")\n")
|
||||||
fmt.Fprintf(&w, "}")
|
fmt.Fprintf(&w, "}")
|
||||||
err := ioutil.WriteFile(tmpdir+"/bigfn.go", w.Bytes(), 0666)
|
err := os.WriteFile(tmpdir+"/bigfn.go", w.Bytes(), 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("can't write output: %v\n", err)
|
t.Fatalf("can't write output: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"internal/godebug"
|
"internal/godebug"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"math/bits"
|
"math/bits"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
@ -963,7 +962,7 @@ func (e *MalformedCorpusError) Error() string {
|
||||||
// be saved in a MalformedCorpusError and returned, along with the most recent
|
// be saved in a MalformedCorpusError and returned, along with the most recent
|
||||||
// error.
|
// error.
|
||||||
func ReadCorpus(dir string, types []reflect.Type) ([]CorpusEntry, error) {
|
func ReadCorpus(dir string, types []reflect.Type) ([]CorpusEntry, error) {
|
||||||
files, err := ioutil.ReadDir(dir)
|
files, err := os.ReadDir(dir)
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
return nil, nil // No corpus to read
|
return nil, nil // No corpus to read
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
|
|
@ -981,7 +980,7 @@ func ReadCorpus(dir string, types []reflect.Type) ([]CorpusEntry, error) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
filename := filepath.Join(dir, file.Name())
|
filename := filepath.Join(dir, file.Name())
|
||||||
data, err := ioutil.ReadFile(filename)
|
data, err := os.ReadFile(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to read corpus file: %v", err)
|
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 {
|
if err := os.MkdirAll(dir, 0777); err != nil {
|
||||||
return err
|
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
|
os.Remove(entry.Path) // remove partially written file
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ package fuzz
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
@ -65,7 +64,7 @@ func sharedMemSize(valueSize int) int {
|
||||||
// it into memory. The file will be removed when the Close method is called.
|
// it into memory. The file will be removed when the Close method is called.
|
||||||
func sharedMemTempFile(size int) (m *sharedMem, err error) {
|
func sharedMemTempFile(size int) (m *sharedMem, err error) {
|
||||||
// Create a temporary file.
|
// Create a temporary file.
|
||||||
f, err := ioutil.TempFile("", "fuzz-*")
|
f, err := os.CreateTemp("", "fuzz-*")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
@ -958,7 +957,7 @@ func (wc *workerClient) Close() error {
|
||||||
|
|
||||||
// Drain fuzzOut and close it. When the server exits, the kernel will close
|
// Drain fuzzOut and close it. When the server exits, the kernel will close
|
||||||
// its end of fuzzOut, and we'll get EOF.
|
// 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()
|
wc.fuzzOut.Close()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ package txtar
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -66,7 +66,7 @@ func Format(a *Archive) []byte {
|
||||||
|
|
||||||
// ParseFile parses the named file as an archive.
|
// ParseFile parses the named file as an archive.
|
||||||
func ParseFile(file string) (*Archive, error) {
|
func ParseFile(file string) (*Archive, error) {
|
||||||
data, err := ioutil.ReadFile(file)
|
data, err := os.ReadFile(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue