refactor: move from io/ioutil to io and os package
The io/ioutil package has been deprecated as of Go 1.16, see https://golang.org/doc/go1.16#ioutil. This commit replaces the existing io/ioutil functions with their new definitions in io and os packages. Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
@@ -18,7 +18,6 @@ package container
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
@@ -182,7 +181,7 @@ func StoreStatus(root, id string, status Status) (StatusStorage, error) {
|
||||
// writing to the file during loading.
|
||||
func LoadStatus(root, id string) (Status, error) {
|
||||
path := filepath.Join(root, "status")
|
||||
data, err := ioutil.ReadFile(path)
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return Status{}, errors.Wrapf(err, "failed to read status from %q", path)
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ package container
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
@@ -115,7 +114,7 @@ func TestStatus(t *testing.T) {
|
||||
assert := assertlib.New(t)
|
||||
require := requirelib.New(t)
|
||||
|
||||
tempDir, err := ioutil.TempDir(os.TempDir(), "status-test")
|
||||
tempDir, err := os.MkdirTemp(os.TempDir(), "status-test")
|
||||
require.NoError(err)
|
||||
defer os.RemoveAll(tempDir)
|
||||
statusFile := filepath.Join(tempDir, "status")
|
||||
|
||||
Reference in New Issue
Block a user