Skip to content

Commit 5462ce0

Browse files
committed
chore: remove refs to deprecated io/ioutil
1 parent 744da80 commit 5462ce0

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

dirs.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
package main
66

77
import (
8-
"io/ioutil"
8+
"os"
99
)
1010

1111
// Dirs returns a slice of all the directories within a given directory
1212
func Dirs(path string) []string {
13-
files, err := ioutil.ReadDir(path)
13+
files, err := os.ReadDir(path)
1414
if err != nil {
1515
return nil
1616
}

main_test.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ package main
77
import (
88
"bytes"
99
"fmt"
10-
"io/ioutil"
1110
"log"
1211
"os"
1312
"os/exec"
@@ -101,7 +100,7 @@ func TestGofmt(t *testing.T) {
101100

102101
func TestGoPyErrors(t *testing.T) {
103102
pyvm := testBackends["py3"]
104-
workdir, err := ioutil.TempDir("", "gopy-")
103+
workdir, err := os.MkdirTemp("", "gopy-")
105104
if err != nil {
106105
t.Fatalf("could not create workdir: %v\n", err)
107106
}
@@ -886,14 +885,14 @@ don't modify manually.
886885
}
887886

888887
if os.Getenv("GOPY_GENERATE_SUPPORT_MATRIX") == "1" {
889-
err := ioutil.WriteFile("SUPPORT_MATRIX.md", buf.Bytes(), 0644)
888+
err := os.WriteFile("SUPPORT_MATRIX.md", buf.Bytes(), 0644)
890889
if err != nil {
891890
log.Fatalf("Unable to write SUPPORT_MATRIX.md")
892891
}
893892
return
894893
}
895894

896-
src, err := ioutil.ReadFile("SUPPORT_MATRIX.md")
895+
src, err := os.ReadFile("SUPPORT_MATRIX.md")
897896
if err != nil {
898897
log.Fatalf("Unable to read SUPPORT_MATRIX.md")
899898
}
@@ -952,7 +951,7 @@ require github.com/go-python/gopy v0.0.0
952951
replace github.com/go-python/gopy => %s
953952
`
954953
contents := fmt.Sprintf(template, pkgDir)
955-
if err := ioutil.WriteFile(filepath.Join(tstDir, "go.mod"), []byte(contents), 0666); err != nil {
954+
if err := os.WriteFile(filepath.Join(tstDir, "go.mod"), []byte(contents), 0666); err != nil {
956955
t.Fatalf("failed to write go.mod file: %v", err)
957956
}
958957
}
@@ -961,7 +960,7 @@ func testPkgBackend(t *testing.T, pyvm string, table pkg) {
961960
curPkgPath := reflect.TypeOf(table).PkgPath()
962961
_, pkgNm := filepath.Split(table.path)
963962
cwd, _ := os.Getwd()
964-
workdir, err := ioutil.TempDir("", "gopy-")
963+
workdir, err := os.MkdirTemp("", "gopy-")
965964
if err != nil {
966965
t.Fatalf("[%s:%s]: could not create workdir: %v\n", pyvm, table.path, err)
967966
}

0 commit comments

Comments
 (0)