Remove io/ioutil use

See https://golang.org/doc/go1.16#ioutil

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin
2021-10-13 13:24:01 -07:00
parent 6a4f4a6a37
commit 5516294172
28 changed files with 109 additions and 77 deletions
+9 -6
View File
@@ -4,7 +4,6 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"syscall"
@@ -121,7 +120,7 @@ func getContainers(context *cli.Context) ([]containerState, error) {
if err != nil {
return nil, err
}
list, err := ioutil.ReadDir(absRoot)
list, err := os.ReadDir(absRoot)
if err != nil {
fatal(err)
}
@@ -129,11 +128,15 @@ func getContainers(context *cli.Context) ([]containerState, error) {
var s []containerState
for _, item := range list {
if item.IsDir() {
// This cast is safe on Linux.
stat := item.Sys().(*syscall.Stat_t)
owner, err := user.LookupUid(int(stat.Uid))
st, err := os.Stat(filepath.Join(absRoot, item.Name()))
if err != nil {
owner.Name = fmt.Sprintf("#%d", stat.Uid)
fatal(err)
}
// This cast is safe on Linux.
uid := st.Sys().(*syscall.Stat_t).Uid
owner, err := user.LookupUid(int(uid))
if err != nil {
owner.Name = fmt.Sprintf("#%d", uid)
}
container, err := factory.Load(item.Name())