Skip to content

Commit

Permalink
refactor: remove io/ioutil
Browse files Browse the repository at this point in the history
io/ioutil has been deprecated since Go 1.16
https://pkg.go.dev/io/ioutil

Signed-off-by: ginglis13 <[email protected]>
  • Loading branch information
ginglis13 committed Oct 13, 2023
1 parent abd6a89 commit 7f6c0c8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
5 changes: 2 additions & 3 deletions e2e/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"flag"
"fmt"
"io"
"io/ioutil"
"os"
"os/signal"
"path/filepath"
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions pkg/stdlib/io/fs/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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")
Expand Down
3 changes: 1 addition & 2 deletions pkg/stdlib/io/fs/util_test.go
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down

0 comments on commit 7f6c0c8

Please sign in to comment.