Skip to content

Commit

Permalink
Merge pull request #498 from toqueteos/remove-deprecated-ioutil
Browse files Browse the repository at this point in the history
Remove io/ioutil usages (deprecated since Go 1.16)
  • Loading branch information
yuin authored Nov 9, 2024
2 parents 91b4cff + b5e3b3f commit 7f73012
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
7 changes: 3 additions & 4 deletions auxlib_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package lua

import (
"io/ioutil"
"os"
"testing"
)
Expand Down Expand Up @@ -300,10 +299,10 @@ func TestOptChannel(t *testing.T) {
}

func TestLoadFileForShebang(t *testing.T) {
tmpFile, err := ioutil.TempFile("", "")
tmpFile, err := os.CreateTemp("", "")
errorIfNotNil(t, err)

err = ioutil.WriteFile(tmpFile.Name(), []byte(`#!/path/to/lua
err = os.WriteFile(tmpFile.Name(), []byte(`#!/path/to/lua
print("hello")
`), 0644)
errorIfNotNil(t, err)
Expand All @@ -321,7 +320,7 @@ print("hello")
}

func TestLoadFileForEmptyFile(t *testing.T) {
tmpFile, err := ioutil.TempFile("", "")
tmpFile, err := os.CreateTemp("", "")
errorIfNotNil(t, err)

defer func() {
Expand Down
5 changes: 2 additions & 3 deletions iolib.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"os"
"os/exec"
"syscall"
Expand Down Expand Up @@ -373,7 +372,7 @@ func fileReadAux(L *LState, file *lFile, idx int) int {
L.Push(v)
case 'a':
var buf []byte
buf, err = ioutil.ReadAll(file.reader)
buf, err = io.ReadAll(file.reader)
if err == io.EOF {
L.Push(emptyLString)
goto normalreturn
Expand Down Expand Up @@ -704,7 +703,7 @@ func ioType(L *LState) int {
}

func ioTmpFile(L *LState) int {
file, err := ioutil.TempFile("", "")
file, err := os.CreateTemp("", "")
if err != nil {
L.Push(LNil)
L.Push(LString(err.Error()))
Expand Down
3 changes: 1 addition & 2 deletions oslib.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package lua

import (
"io/ioutil"
"os"
"strings"
"time"
Expand Down Expand Up @@ -223,7 +222,7 @@ func osTime(L *LState) int {
}

func osTmpname(L *LState) int {
file, err := ioutil.TempFile("", "")
file, err := os.CreateTemp("", "")
if err != nil {
L.RaiseError("unable to generate a unique filename")
}
Expand Down

0 comments on commit 7f73012

Please sign in to comment.