Skip to content

Commit cddb2b2

Browse files
committed
fix ioutil deprecation warnings
Seen in github.com//pull/164. Signed-off-by: Valentin Rothberg <[email protected]>
1 parent eb14b76 commit cddb2b2

File tree

5 files changed

+9
-10
lines changed

5 files changed

+9
-10
lines changed

internal/host/host_nocgo.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build !cgo
12
// +build !cgo
23

34
// Copyright 2018 psgo authors
@@ -21,7 +22,7 @@ package host
2122
import (
2223
"encoding/binary"
2324
"fmt"
24-
"io/ioutil"
25+
"os"
2526
"unsafe"
2627
)
2728

@@ -46,7 +47,7 @@ const (
4647

4748
func getFromAuxv(what uint, whatName string) (uint, error) {
4849
dataLen := int(unsafe.Sizeof(int(0)))
49-
p, err := ioutil.ReadFile("/proc/self/auxv")
50+
p, err := os.ReadFile("/proc/self/auxv")
5051
if err != nil {
5152
return 0, err
5253
}

internal/proc/attr.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ package proc
1717
import (
1818
"errors"
1919
"fmt"
20-
"io/ioutil"
2120
"os"
2221
"strings"
2322

@@ -27,7 +26,7 @@ import (
2726
// ParseAttrCurrent returns the contents of /proc/$pid/attr/current of "?" if
2827
// labeling is not supported on the host.
2928
func ParseAttrCurrent(pid string) (string, error) {
30-
data, err := ioutil.ReadFile(fmt.Sprintf("/proc/%s/attr/current", pid))
29+
data, err := os.ReadFile(fmt.Sprintf("/proc/%s/attr/current", pid))
3130
if err != nil {
3231
_, err = os.Stat(fmt.Sprintf("/proc/%s", pid))
3332
if errors.Is(err, os.ErrNotExist) || errors.Is(err, unix.ESRCH) {

internal/proc/cmdline.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ package proc
1717
import (
1818
"bytes"
1919
"fmt"
20-
"io/ioutil"
20+
"os"
2121
)
2222

2323
// ParseCmdLine parses a /proc/$pid/cmdline file and returns a string slice.
2424
func ParseCmdLine(pid string) ([]string, error) {
25-
data, err := ioutil.ReadFile(fmt.Sprintf("/proc/%s/cmdline", pid))
25+
data, err := os.ReadFile(fmt.Sprintf("/proc/%s/cmdline", pid))
2626
if err != nil {
2727
return nil, err
2828
}

internal/proc/stat.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ package proc
1717
import (
1818
"errors"
1919
"fmt"
20-
"io/ioutil"
20+
"os"
2121
"strings"
2222
)
2323

@@ -114,7 +114,7 @@ type Stat struct {
114114

115115
// readStat is used for mocking in unit tests.
116116
var readStat = func(path string) (string, error) {
117-
rawData, err := ioutil.ReadFile(path)
117+
rawData, err := os.ReadFile(path)
118118
if err != nil {
119119
return "", err
120120
}

psgo.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ package psgo
2929
import (
3030
"errors"
3131
"fmt"
32-
"io/ioutil"
3332
"os"
3433
"runtime"
3534
"sort"
@@ -110,7 +109,7 @@ func findID(idStr string, mapping []idtools.IDMap, lookupFunc func(uid string) (
110109
}
111110

112111
// User not found, read the overflow
113-
overflow, err := ioutil.ReadFile(overflowFile)
112+
overflow, err := os.ReadFile(overflowFile)
114113
if err != nil {
115114
return "", err
116115
}

0 commit comments

Comments
 (0)