Skip to content

Commit

Permalink
Stop using deprecated ioutil
Browse files Browse the repository at this point in the history
  • Loading branch information
tchajed committed Jul 12, 2024
1 parent 8e8d743 commit 6eb6bb6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
3 changes: 1 addition & 2 deletions cmd/test_gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"bufio"
"flag"
"fmt"
"io/ioutil"
"os"
"path"
"regexp"
Expand Down Expand Up @@ -96,7 +95,7 @@ func main() {
os.Exit(1)
}
srcDir := flag.Arg(0)
files, err := ioutil.ReadDir(srcDir)
files, err := os.ReadDir(srcDir)
if err != nil {
panic(err)
}
Expand Down
7 changes: 3 additions & 4 deletions examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"go/ast"
"go/parser"
"go/token"
"io/ioutil"
"os"
"path"
"regexp"
Expand Down Expand Up @@ -85,7 +84,7 @@ func (t positiveTest) ActualFile() string {

// Gold returns the contents of the gold Ast as a string
func (t positiveTest) Gold() string {
expected, err := ioutil.ReadFile(t.GoldFile())
expected, err := os.ReadFile(t.GoldFile())
if err != nil {
return ""
}
Expand All @@ -94,15 +93,15 @@ func (t positiveTest) Gold() string {

// UpdateGold updates the gold output with real results
func (t positiveTest) UpdateGold(actual string) {
err := ioutil.WriteFile(t.GoldFile(), []byte(actual), 0644)
err := os.WriteFile(t.GoldFile(), []byte(actual), 0644)
if err != nil {
panic(err)
}
}

// PutActual updates the actual test output with the real results
func (t positiveTest) PutActual(actual string) {
err := ioutil.WriteFile(t.ActualFile(), []byte(actual), 0644)
err := os.WriteFile(t.ActualFile(), []byte(actual), 0644)
if err != nil {
panic(err)
}
Expand Down
3 changes: 1 addition & 2 deletions machine/filesys/filesys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package filesys_test

import (
"fmt"
"io/ioutil"
"os"
"sort"
"testing"
Expand All @@ -23,7 +22,7 @@ func (s *FilesysSuite) SetupTest() {
s.fs = filesys.NewMemFs()
} else {
var err error
s.dir, err = ioutil.TempDir("", "test.dir")
s.dir, err = os.MkdirTemp("", "test.dir")
if err != nil {
panic(err)
}
Expand Down

0 comments on commit 6eb6bb6

Please sign in to comment.