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:
Andy Pan 2022-08-28 03:38:00 +08:00 committed by Gopher Robot
parent 1e7e160d07
commit f8c659b62f
67 changed files with 255 additions and 290 deletions

View file

@ -32,6 +32,21 @@ package ld
import (
"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/goobj"
"cmd/internal/notsha256"
@ -43,21 +58,6 @@ import (
"cmd/link/internal/loadpe"
"cmd/link/internal/loadxcoff"
"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.
@ -1157,7 +1157,7 @@ func hostlinksetup(ctxt *Link) {
// create temporary directory and arrange cleanup
if *flagTmpdir == "" {
dir, err := ioutil.TempDir("", "go-link-")
dir, err := os.MkdirTemp("", "go-link-")
if err != nil {
log.Fatal(err)
}
@ -1238,7 +1238,7 @@ func writeGDBLinkerScript() string {
}
INSERT AFTER .debug_types;
`
err := ioutil.WriteFile(path, []byte(src), 0666)
err := os.WriteFile(path, []byte(src), 0666)
if err != nil {
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 {
createTrivialCOnce.Do(func() {
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)
}
})