Skip to content

Commit

Permalink
refactor: rm io/ioutil funcs
Browse files Browse the repository at this point in the history
io/ioutil has been deprecated since Go 1.16
https://pkg.go.dev/io/ioutil

Signed-off-by: ginglis13 <[email protected]>
  • Loading branch information
ginglis13 committed Oct 14, 2023
1 parent 2d43076 commit aaf00ad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
5 changes: 2 additions & 3 deletions loader/goroot.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"errors"
"io"
"io/fs"
"io/ioutil"
"os"
"os/exec"
"path"
Expand Down Expand Up @@ -157,7 +156,7 @@ func listGorootMergeLinks(goroot, tinygoroot string, overrides map[string]bool)

// Add files from TinyGo.
tinygoDir := filepath.Join(tinygoSrc, dir)
tinygoEntries, err := ioutil.ReadDir(tinygoDir)
tinygoEntries, err := os.ReadDir(tinygoDir)
if err != nil {
return nil, err
}
Expand All @@ -177,7 +176,7 @@ func listGorootMergeLinks(goroot, tinygoroot string, overrides map[string]bool)
// Add all directories from $GOROOT that are not part of the TinyGo
// overrides.
goDir := filepath.Join(goSrc, dir)
goEntries, err := ioutil.ReadDir(goDir)
goEntries, err := os.ReadDir(goDir)
if err != nil {
return nil, err
}
Expand Down
11 changes: 8 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"go/scanner"
"go/types"
"io"
"io/ioutil"
"os"
"os/exec"
"os/signal"
Expand Down Expand Up @@ -1736,14 +1735,20 @@ func main() {
handleCompilerError(err)
case "targets":
dir := filepath.Join(goenv.Get("TINYGOROOT"), "targets")
entries, err := ioutil.ReadDir(dir)
entries, err := os.ReadDir(dir)
if err != nil {
fmt.Fprintln(os.Stderr, "could not list targets:", err)
os.Exit(1)
return
}
for _, entry := range entries {
if !entry.Mode().IsRegular() || !strings.HasSuffix(entry.Name(), ".json") {
entryInfo, err := entry.Info()
if err != nil {
fmt.Fprintln(os.Stderr, "could not get entry info:", err)
os.Exit(1)
return
}
if !entryInfo.Mode().IsRegular() || !strings.HasSuffix(entry.Name(), ".json") {
// Only inspect JSON files.
continue
}
Expand Down

0 comments on commit aaf00ad

Please sign in to comment.