Skip to content

Commit

Permalink
ioutil got deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonak-Adipta-Kalita committed Sep 13, 2023
1 parent f21db25 commit 95a881a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions evaluator/evaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package evaluator
import (
"fmt"
"io"
"io/ioutil"
"math"
"os"

Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions object/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"fmt"
"hash/fnv"
"io/ioutil"
"io"
"os"
"strconv"
"strings"
Expand Down Expand Up @@ -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())}
Expand All @@ -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())}
}
Expand Down

0 comments on commit 95a881a

Please sign in to comment.