Skip to content

Commit

Permalink
unix: remove the use of ioutil
Browse files Browse the repository at this point in the history
Trivial changes.

Change-Id: If7ffa47bb4c3b2bae784091e94516b0f4fc197d2
Reviewed-on: https://go-review.googlesource.com/c/sys/+/526300
Reviewed-by: Tobias Klauser <[email protected]>
Reviewed-by: Heschi Kreinick <[email protected]>
Run-TryBot: Kirill Kolyshkin <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Auto-Submit: Tobias Klauser <[email protected]>
  • Loading branch information
kolyshkin authored and gopherbot committed Sep 13, 2023
1 parent 38ebf41 commit 5a17dda
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 17 deletions.
5 changes: 2 additions & 3 deletions unix/internal/mkmerge/mkmerge.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (
"go/parser"
"go/token"
"io"
"io/ioutil"
"log"
"os"
"path"
Expand Down Expand Up @@ -433,7 +432,7 @@ func merge(mergedFile string, archFiles ...string) error {
// Read architecture files
var inSrc []srcFile
for _, file := range archFiles {
src, err := ioutil.ReadFile(file)
src, err := os.ReadFile(file)
if err != nil {
return fmt.Errorf("cannot read archfile %s: %w", file, err)
}
Expand Down Expand Up @@ -485,7 +484,7 @@ func merge(mergedFile string, archFiles ...string) error {
if err != nil {
return err
}
err = ioutil.WriteFile(inFile.name, src, 0644)
err = os.WriteFile(inFile.name, src, 0644)
if err != nil {
return err
}
Expand Down
3 changes: 1 addition & 2 deletions unix/linux/mkall.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"fmt"
"go/build/constraint"
"io"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -810,7 +809,7 @@ func generatePtraceRegSet(arch string) error {
// ptraceDef returns the definition of PtraceRegs for arch.
func ptraceDef(arch string) (string, error) {
filename := fmt.Sprintf("ztypes_linux_%s.go", arch)
data, err := ioutil.ReadFile(filename)
data, err := os.ReadFile(filename)
if err != nil {
return "", fmt.Errorf("reading %s: %v", filename, err)
}
Expand Down
7 changes: 3 additions & 4 deletions unix/mkasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ package main
import (
"bytes"
"fmt"
"io/ioutil"
"log"
"os"
"sort"
Expand All @@ -35,7 +34,7 @@ func generateASMFile(goos, arch string, inFileNames []string, outFileName string
trampolines := map[string]bool{}
var orderedTrampolines []string
for _, inFileName := range inFileNames {
in, err := ioutil.ReadFile(inFileName)
in, err := os.ReadFile(inFileName)
if err != nil {
log.Fatalf("Failed to read file: %v", err)
}
Expand Down Expand Up @@ -72,7 +71,7 @@ func generateASMFile(goos, arch string, inFileNames []string, outFileName string
fmt.Fprintf(&out, "DATA\t·%s_trampoline_addr(SB)/%d, $%s_trampoline<>(SB)\n", fn, ptrSize, fn)
}

if err := ioutil.WriteFile(outFileName, out.Bytes(), 0644); err != nil {
if err := os.WriteFile(outFileName, out.Bytes(), 0644); err != nil {
log.Fatalf("Failed to write assembly file %q: %v", outFileName, err)
}

Expand Down Expand Up @@ -110,7 +109,7 @@ func writeDarwinTest(trampolines map[string]bool, fileName, arch string) {
out.Reset()
fmt.Fprintf(&out, darwinTestTemplate, strings.Join(os.Args[1:], " "), arch, lines)

if err := ioutil.WriteFile(fileName, out.Bytes(), 0644); err != nil {
if err := os.WriteFile(fileName, out.Bytes(), 0644); err != nil {
log.Fatalf("Failed to write test file %q: %v", fileName, err)
}
}
Expand Down
4 changes: 2 additions & 2 deletions unix/mkpost.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"bytes"
"fmt"
"go/format"
"io/ioutil"
"io"
"log"
"os"
"regexp"
Expand All @@ -41,7 +41,7 @@ func main() {
}
}

b, err := ioutil.ReadAll(os.Stdin)
b, err := io.ReadAll(os.Stdin)
if err != nil {
log.Fatal(err)
}
Expand Down
7 changes: 3 additions & 4 deletions unix/mksyscall_aix_ppc64.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ import (
"bufio"
"flag"
"fmt"
"io/ioutil"
"os"
"regexp"
"strings"
Expand Down Expand Up @@ -525,7 +524,7 @@ func main() {
}

// Print zsyscall_aix_ppc64.go
err := ioutil.WriteFile("zsyscall_aix_ppc64.go",
err := os.WriteFile("zsyscall_aix_ppc64.go",
[]byte(fmt.Sprintf(srcTemplate1, cmdLine(), goBuildTags(), plusBuildTags(), pack, imp, textcommon)),
0644)
if err != nil {
Expand All @@ -536,7 +535,7 @@ func main() {
// Print zsyscall_aix_ppc64_gc.go
vardecls := "\t" + strings.Join(vars, ",\n\t")
vardecls += " syscallFunc"
err = ioutil.WriteFile("zsyscall_aix_ppc64_gc.go",
err = os.WriteFile("zsyscall_aix_ppc64_gc.go",
[]byte(fmt.Sprintf(srcTemplate2, cmdLine(), goBuildTags(), plusBuildTags(), pack, imp, dynimports, linknames, vardecls, textgc)),
0644)
if err != nil {
Expand All @@ -545,7 +544,7 @@ func main() {
}

// Print zsyscall_aix_ppc64_gccgo.go
err = ioutil.WriteFile("zsyscall_aix_ppc64_gccgo.go",
err = os.WriteFile("zsyscall_aix_ppc64_gccgo.go",
[]byte(fmt.Sprintf(srcTemplate3, cmdLine(), goBuildTags(), plusBuildTags(), pack, cExtern, imp, textgccgo)),
0644)
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions unix/mksysnum.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"bufio"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"regexp"
Expand Down Expand Up @@ -67,7 +66,7 @@ func fetchFile(URL string) io.Reader {
resp, err := http.Get(URL)
checkErr(err)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
checkErr(err)
return strings.NewReader(string(body))
}
Expand Down

0 comments on commit 5a17dda

Please sign in to comment.