Skip to content

Commit

Permalink
Replace deprecated io/ioutil package with os
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandear committed Aug 25, 2023
1 parent ca59e56 commit 2c81dfd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions fmttests/datadriven_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
goErr "errors"
"flag"
"fmt"
"io/ioutil"
"net"
"os"
"regexp"
Expand Down Expand Up @@ -385,7 +384,7 @@ func generateFiles() {
}
leafTests.WriteString("----\n\n")
}
ioutil.WriteFile(testPath+"/leaves", leafTests.Bytes(), 0666)
os.WriteFile(testPath+"/leaves", leafTests.Bytes(), 0666)

// Generate the "leaves-via-network" input file, which tests
// formatting for leaf-only error types after being brought over
Expand All @@ -405,7 +404,7 @@ func generateFiles() {
}
leafTests.WriteString("----\n\n")
}
ioutil.WriteFile(testPath+"/leaves-via-network", leafTests.Bytes(), 0666)
os.WriteFile(testPath+"/leaves-via-network", leafTests.Bytes(), 0666)

// Leaf types for which we want to test all wrappers:
wrapperLeafTypes := []string{"fmt", "goerr", "nofmt", "pkgerr", "newf"}
Expand Down Expand Up @@ -449,7 +448,7 @@ func generateFiles() {
}
wrapTests.WriteString("----\n\n")
}
ioutil.WriteFile(
os.WriteFile(
fmt.Sprintf(testPath+"/wrap-%s", leafName),
wrapTests.Bytes(), 0666)
}
Expand Down Expand Up @@ -490,7 +489,7 @@ func generateFiles() {
}
wrapTests.WriteString("----\n\n")
}
ioutil.WriteFile(
os.WriteFile(
fmt.Sprintf(testPath+"/wrap-%s-via-network", leafName),
wrapTests.Bytes(), 0666)
}
Expand Down
4 changes: 2 additions & 2 deletions testutils/simplecheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package testutils
import (
"bytes"
"fmt"
"io/ioutil"
"os"
"reflect"
"regexp"
"runtime"
Expand Down Expand Up @@ -212,7 +212,7 @@ func fileContext(filename string, line, context int) ([][]byte, int) {
defer fileCacheLock.Unlock()
lines, ok := fileCache[filename]
if !ok {
data, err := ioutil.ReadFile(filename)
data, err := os.ReadFile(filename)
if err != nil {
// cache errors as nil slice: code below handles it correctly
// otherwise when missing the source or running as a different user, we try
Expand Down

0 comments on commit 2c81dfd

Please sign in to comment.