1
0
mirror of https://github.com/MontFerret/ferret.git synced 2025-08-13 19:52:52 +02:00

refactor: remove io/ioutil (#792)

io/ioutil has been deprecated since Go 1.16
https://pkg.go.dev/io/ioutil

Signed-off-by: ginglis13 <ginglis05@gmail.com>
This commit is contained in:
Gavin Inglis
2025-05-07 07:51:10 -07:00
committed by GitHub
parent 24752c0f48
commit 0f3526c178
3 changed files with 5 additions and 7 deletions

View File

@@ -8,7 +8,6 @@ import (
"flag" "flag"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"os" "os"
"os/signal" "os/signal"
"path/filepath" "path/filepath"
@@ -337,7 +336,7 @@ func execFiles(ctx context.Context, engine *ferret.Instance, opts []runtime.Opti
if info.IsDir() { if info.IsDir() {
log.Debug().Msg("path points to a directory. retrieving list of files...") 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 { if err != nil {
log.Debug().Err(err).Msg("failed to retrieve list of files") 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") 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 { if err != nil {
log.Debug().Err(err).Msg("failed to read content") log.Debug().Err(err).Msg("failed to read content")

View File

@@ -2,7 +2,7 @@ package fs
import ( import (
"context" "context"
"io/ioutil" "os"
"github.com/MontFerret/ferret/pkg/runtime/core" "github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values" "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() path := args[0].String()
data, err := ioutil.ReadFile(path) data, err := os.ReadFile(path)
if err != nil { if err != nil {
return values.None, core.Error(err, "read file") return values.None, core.Error(err, "read file")

View File

@@ -1,14 +1,13 @@
package fs_test package fs_test
import ( import (
"io/ioutil"
"os" "os"
. "github.com/smartystreets/goconvey/convey" . "github.com/smartystreets/goconvey/convey"
) )
func tempFile() (*os.File, func()) { func tempFile() (*os.File, func()) {
file, err := ioutil.TempFile("", "fstest") file, err := os.CreateTemp("", "fstest")
So(err, ShouldBeNil) So(err, ShouldBeNil)
fn := func() { fn := func() {