From fc700c20cc15a2d5ab3b5d61f4017ecf5603a931 Mon Sep 17 00:00:00 2001 From: Austin Vazquez Date: Mon, 24 Oct 2022 22:05:07 +0000 Subject: [PATCH] Remove references to io/ioutil io/ioutil package has been marked deprecated in Go 1.16 Signed-off-by: Austin Vazquez --- console.go | 3 +-- runc.go | 3 +-- runc_test.go | 3 +-- utils.go | 4 ++-- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/console.go b/console.go index cff137b..ac639f3 100644 --- a/console.go +++ b/console.go @@ -21,7 +21,6 @@ package runc import ( "fmt" - "io/ioutil" "net" "os" "path/filepath" @@ -54,7 +53,7 @@ func NewConsoleSocket(path string) (*Socket, error) { // On Close(), the socket is deleted func NewTempConsoleSocket() (*Socket, error) { runtimeDir := os.Getenv("XDG_RUNTIME_DIR") - dir, err := ioutil.TempDir(runtimeDir, "pty") + dir, err := os.MkdirTemp(runtimeDir, "pty") if err != nil { return nil, err } diff --git a/runc.go b/runc.go index 61ba491..2a6e621 100644 --- a/runc.go +++ b/runc.go @@ -23,7 +23,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "os" "os/exec" "path/filepath" @@ -261,7 +260,7 @@ func (r *Runc) Exec(context context.Context, id string, spec specs.Process, opts if opts.Started != nil { defer close(opts.Started) } - f, err := ioutil.TempFile(os.Getenv("XDG_RUNTIME_DIR"), "runc-process") + f, err := os.CreateTemp(os.Getenv("XDG_RUNTIME_DIR"), "runc-process") if err != nil { return err } diff --git a/runc_test.go b/runc_test.go index 4b1275a..777201b 100644 --- a/runc_test.go +++ b/runc_test.go @@ -19,7 +19,6 @@ package runc import ( "context" "errors" - "io/ioutil" "os" "sync" "syscall" @@ -290,7 +289,7 @@ func interrupt(ctx context.Context, t *testing.T, started <-chan int) { // dummySleepRunc creates s simple script that just runs `sleep 10` to replace // runc for testing process that are longer running. func dummySleepRunc() (_ string, err error) { - fh, err := ioutil.TempFile("", "*.sh") + fh, err := os.CreateTemp("", "*.sh") if err != nil { return "", err } diff --git a/utils.go b/utils.go index 312cb02..4f39f6e 100644 --- a/utils.go +++ b/utils.go @@ -18,7 +18,7 @@ package runc import ( "bytes" - "io/ioutil" + "os" "strconv" "strings" "sync" @@ -27,7 +27,7 @@ import ( // ReadPidFile reads the pid file at the provided path and returns // the pid or an error if the read and conversion is unsuccessful func ReadPidFile(path string) (int, error) { - data, err := ioutil.ReadFile(path) + data, err := os.ReadFile(path) if err != nil { return -1, err }