Skip to content

Remove usages of io/ioutil #1262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading