From 5d71edf31f894f48803f5b30a0eb6c229beb8964 Mon Sep 17 00:00:00 2001 From: Carlos Cobo <699969+toqueteos@users.noreply.github.com> Date: Mon, 16 Sep 2024 11:05:56 +0200 Subject: [PATCH] Remove usages of io/ioutil (#1262) Package deprecated since Go 1.16 --- console/openapi-gen-angular/main.go | 3 +-- internal/gopher-lua/auxlib_test.go | 7 +++---- internal/gopher-lua/iolib.go | 5 ++--- internal/gopher-lua/oslib.go | 3 +-- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/console/openapi-gen-angular/main.go b/console/openapi-gen-angular/main.go index eedb811df4..f07822bfd0 100644 --- a/console/openapi-gen-angular/main.go +++ b/console/openapi-gen-angular/main.go @@ -19,7 +19,6 @@ import ( "encoding/json" "flag" "fmt" - "io/ioutil" "os" "regexp" "strings" @@ -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 diff --git a/internal/gopher-lua/auxlib_test.go b/internal/gopher-lua/auxlib_test.go index 2218db67e8..625150b660 100644 --- a/internal/gopher-lua/auxlib_test.go +++ b/internal/gopher-lua/auxlib_test.go @@ -1,7 +1,6 @@ package lua import ( - "io/ioutil" "os" "testing" ) @@ -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) @@ -319,7 +318,7 @@ print("hello") } func TestLoadFileForEmptyFile(t *testing.T) { - tmpFile, err := ioutil.TempFile("", "") + tmpFile, err := os.CreateTemp("", "") errorIfNotNil(t, err) defer func() { diff --git a/internal/gopher-lua/iolib.go b/internal/gopher-lua/iolib.go index 4a86f89362..a50ca8e6ed 100644 --- a/internal/gopher-lua/iolib.go +++ b/internal/gopher-lua/iolib.go @@ -5,7 +5,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "os" "os/exec" "syscall" @@ -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 @@ -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())) diff --git a/internal/gopher-lua/oslib.go b/internal/gopher-lua/oslib.go index 256c881130..099a358c13 100644 --- a/internal/gopher-lua/oslib.go +++ b/internal/gopher-lua/oslib.go @@ -1,7 +1,6 @@ package lua import ( - "io/ioutil" "os" "strings" "time" @@ -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") }