From 95a881aa242e5885e255c35f742a7d604f12187a Mon Sep 17 00:00:00 2001 From: Jonak-Adipta-Kalita Date: Wed, 13 Sep 2023 16:43:04 +0530 Subject: [PATCH] ioutil got deprecated --- evaluator/evaluator.go | 3 +-- object/object.go | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/evaluator/evaluator.go b/evaluator/evaluator.go index 0789020..6cb04f3 100644 --- a/evaluator/evaluator.go +++ b/evaluator/evaluator.go @@ -3,7 +3,6 @@ package evaluator import ( "fmt" "io" - "io/ioutil" "math" "os" @@ -678,7 +677,7 @@ func evalForLoopExpression(fle *ast.ForLoopExpression, env *object.Environment) func evalImportStatement(is *ast.ImportStatement, env *object.Environment) { filePath := is.Path.Value file.SetFileName(filePath) - contents, err := ioutil.ReadFile(filePath) + contents, err := os.ReadFile(filePath) if err != nil { fmt.Printf("Failure to read file '%s'. Err: %s", string(contents), err) diff --git a/object/object.go b/object/object.go index 5be84cc..2e5d85b 100644 --- a/object/object.go +++ b/object/object.go @@ -4,7 +4,7 @@ import ( "bytes" "fmt" "hash/fnv" - "io/ioutil" + "io" "os" "strconv" "strings" @@ -456,7 +456,7 @@ func (f *File) InvokeMethod(method string, args ...Object) Object { return &Null{} case "read": - content, err := ioutil.ReadAll(f.File) + content, err := io.ReadAll(f.File) if err != nil { return &Error{Message: fmt.Sprintf("Could not read file: %s", f.File.Name())} @@ -480,7 +480,7 @@ func (f *File) InvokeMethod(method string, args ...Object) Object { return &Null{} case "readlines": - content, err := ioutil.ReadAll(f.File) + content, err := io.ReadAll(f.File) if err != nil { return &Error{Message: fmt.Sprintf("Could not read file: %s", f.File.Name())} }