diff --git a/benchmark/data.go b/benchmark/data.go index 71eb91a9..6621b519 100644 --- a/benchmark/data.go +++ b/benchmark/data.go @@ -3,10 +3,10 @@ package benchmark import ( - "io/ioutil" + "os" ) -var largeStructText, _ = ioutil.ReadFile("example.json") +var largeStructText, _ = os.ReadFile("example.json") var xlStructData XLStruct func init() { diff --git a/bootstrap/bootstrap.go b/bootstrap/bootstrap.go index 733123da..da53ec89 100644 --- a/bootstrap/bootstrap.go +++ b/bootstrap/bootstrap.go @@ -8,7 +8,6 @@ package bootstrap import ( "fmt" "go/format" - "io/ioutil" "os" "os/exec" "path/filepath" @@ -88,7 +87,7 @@ func (g *Generator) writeStub() error { // writeMain creates a .go file that launches the generator if 'go run'. func (g *Generator) writeMain() (path string, err error) { - f, err := ioutil.TempFile(filepath.Dir(g.OutName), "easyjson-bootstrap") + f, err := os.CreateTemp(filepath.Dir(g.OutName), "easyjson-bootstrap-*") if err != nil { return "", err } @@ -211,7 +210,7 @@ func (g *Generator) Run() error { } // format file and write to out path - in, err := ioutil.ReadFile(f.Name()) + in, err := os.ReadFile(f.Name()) if err != nil { return err } @@ -219,5 +218,5 @@ func (g *Generator) Run() error { if err != nil { return err } - return ioutil.WriteFile(g.OutName, out, 0644) + return os.WriteFile(g.OutName, out, 0644) } diff --git a/helpers.go b/helpers.go index 6a4b2fdf..47c7956b 100644 --- a/helpers.go +++ b/helpers.go @@ -3,7 +3,6 @@ package easyjson import ( "io" - "io/ioutil" "net/http" "strconv" "unsafe" @@ -109,7 +108,7 @@ func Unmarshal(data []byte, v Unmarshaler) error { // UnmarshalFromReader reads all the data in the reader and decodes as JSON into the object. func UnmarshalFromReader(r io.Reader, v Unmarshaler) error { - data, err := ioutil.ReadAll(r) + data, err := io.ReadAll(r) if err != nil { return err } diff --git a/parser/pkgpath.go b/parser/pkgpath.go index c045c33f..b356c1e7 100644 --- a/parser/pkgpath.go +++ b/parser/pkgpath.go @@ -4,7 +4,6 @@ import ( "bytes" "fmt" "go/build" - "io/ioutil" "os" "os/exec" "path" @@ -111,7 +110,7 @@ func getModulePath(goModPath string) string { pkgPathFromGoModCache.Unlock() }() - data, err := ioutil.ReadFile(goModPath) + data, err := os.ReadFile(goModPath) if err != nil { return "" }