Skip to content

Commit

Permalink
Remove usages of io/ioutil (heroiclabs#1262)
Browse files Browse the repository at this point in the history
Package deprecated since Go 1.16
  • Loading branch information
toqueteos authored Sep 16, 2024
1 parent 12abcf8 commit 5d71edf
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
3 changes: 1 addition & 2 deletions console/openapi-gen-angular/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"os"
"regexp"
"strings"
Expand Down Expand Up @@ -335,7 +334,7 @@ func main() {
"exists": func(s string) bool { return s != "" },
}

content, err := ioutil.ReadFile(*input)
content, err := os.ReadFile(*input)
if err != nil {
fmt.Printf("Unable to read file: %s\n", err)
return
Expand Down
7 changes: 3 additions & 4 deletions internal/gopher-lua/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 @@ -298,10 +297,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 @@ -319,7 +318,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 internal/gopher-lua/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 @@ -701,7 +700,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 internal/gopher-lua/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 @@ -219,7 +218,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 5d71edf

Please sign in to comment.