From 7f6c0c853bd8d8e7d64b2d01b2daa8ad4560c4a1 Mon Sep 17 00:00:00 2001 From: ginglis13 Date: Fri, 13 Oct 2023 15:16:09 -0700 Subject: [PATCH] refactor: remove io/ioutil io/ioutil has been deprecated since Go 1.16 https://pkg.go.dev/io/ioutil Signed-off-by: ginglis13 --- e2e/cli.go | 5 ++--- pkg/stdlib/io/fs/read.go | 4 ++-- pkg/stdlib/io/fs/util_test.go | 3 +-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/e2e/cli.go b/e2e/cli.go index fcfa3d480..210ccae45 100644 --- a/e2e/cli.go +++ b/e2e/cli.go @@ -8,7 +8,6 @@ import ( "flag" "fmt" "io" - "io/ioutil" "os" "os/signal" "path/filepath" @@ -337,7 +336,7 @@ func execFiles(ctx context.Context, engine *ferret.Instance, opts []runtime.Opti if info.IsDir() { log.Debug().Msg("path points to a directory. retrieving list of files...") - fileInfos, err := ioutil.ReadDir(path) + fileInfos, err := os.ReadDir(path) if err != nil { log.Debug().Err(err).Msg("failed to retrieve list of files") @@ -373,7 +372,7 @@ func execFiles(ctx context.Context, engine *ferret.Instance, opts []runtime.Opti log.Debug().Msg("path points to a file. starting to read content") - out, err := ioutil.ReadFile(path) + out, err := os.ReadFile(path) if err != nil { log.Debug().Err(err).Msg("failed to read content") diff --git a/pkg/stdlib/io/fs/read.go b/pkg/stdlib/io/fs/read.go index cfc2394e8..ce08e92a6 100644 --- a/pkg/stdlib/io/fs/read.go +++ b/pkg/stdlib/io/fs/read.go @@ -2,7 +2,7 @@ package fs import ( "context" - "io/ioutil" + "os" "github.com/MontFerret/ferret/pkg/runtime/core" "github.com/MontFerret/ferret/pkg/runtime/values" @@ -27,7 +27,7 @@ func Read(_ context.Context, args ...core.Value) (core.Value, error) { path := args[0].String() - data, err := ioutil.ReadFile(path) + data, err := os.ReadFile(path) if err != nil { return values.None, core.Error(err, "read file") diff --git a/pkg/stdlib/io/fs/util_test.go b/pkg/stdlib/io/fs/util_test.go index 178f4a509..f9318c6fb 100644 --- a/pkg/stdlib/io/fs/util_test.go +++ b/pkg/stdlib/io/fs/util_test.go @@ -1,14 +1,13 @@ package fs_test import ( - "io/ioutil" "os" . "github.com/smartystreets/goconvey/convey" ) func tempFile() (*os.File, func()) { - file, err := ioutil.TempFile("", "fstest") + file, err := os.CreateTemp("", "fstest") So(err, ShouldBeNil) fn := func() {