Skip to content

Commit

Permalink
fix ioutil deprecation warnings
Browse files Browse the repository at this point in the history
Seen in github.com//pull/164.

Signed-off-by: Valentin Rothberg <[email protected]>
  • Loading branch information
vrothberg committed Oct 7, 2024
1 parent a7ca0b3 commit 726f868
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
5 changes: 3 additions & 2 deletions internal/host/host_nocgo.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !cgo
// +build !cgo

// Copyright 2018 psgo authors
Expand All @@ -21,7 +22,7 @@ package host
import (
"encoding/binary"
"fmt"
"io/ioutil"
"os"
"unsafe"
)

Expand All @@ -46,7 +47,7 @@ const (

func getFromAuxv(what uint, whatName string) (uint, error) {
dataLen := int(unsafe.Sizeof(int(0)))
p, err := ioutil.ReadFile("/proc/self/auxv")
p, err := os.ReadFile("/proc/self/auxv")
if err != nil {
return 0, err
}
Expand Down
3 changes: 1 addition & 2 deletions internal/proc/attr.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package proc
import (
"errors"
"fmt"
"io/ioutil"
"os"
"strings"

Expand All @@ -27,7 +26,7 @@ import (
// ParseAttrCurrent returns the contents of /proc/$pid/attr/current of "?" if
// labeling is not supported on the host.
func ParseAttrCurrent(pid string) (string, error) {
data, err := ioutil.ReadFile(fmt.Sprintf("/proc/%s/attr/current", pid))
data, err := os.ReadFile(fmt.Sprintf("/proc/%s/attr/current", pid))
if err != nil {
_, err = os.Stat(fmt.Sprintf("/proc/%s", pid))
if errors.Is(err, os.ErrNotExist) || errors.Is(err, unix.ESRCH) {
Expand Down
4 changes: 2 additions & 2 deletions internal/proc/cmdline.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ package proc
import (
"bytes"
"fmt"
"io/ioutil"
"os"
)

// ParseCmdLine parses a /proc/$pid/cmdline file and returns a string slice.
func ParseCmdLine(pid string) ([]string, error) {
data, err := ioutil.ReadFile(fmt.Sprintf("/proc/%s/cmdline", pid))
data, err := os.ReadFile(fmt.Sprintf("/proc/%s/cmdline", pid))
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions internal/proc/stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package proc
import (
"errors"
"fmt"
"io/ioutil"
"os"
"strings"
)

Expand Down Expand Up @@ -114,7 +114,7 @@ type Stat struct {

// readStat is used for mocking in unit tests.
var readStat = func(path string) (string, error) {
rawData, err := ioutil.ReadFile(path)
rawData, err := os.ReadFile(path)
if err != nil {
return "", err
}
Expand Down
3 changes: 1 addition & 2 deletions psgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ package psgo
import (
"errors"
"fmt"
"io/ioutil"
"os"
"runtime"
"sort"
Expand Down Expand Up @@ -110,7 +109,7 @@ func findID(idStr string, mapping []idtools.IDMap, lookupFunc func(uid string) (
}

// User not found, read the overflow
overflow, err := ioutil.ReadFile(overflowFile)
overflow, err := os.ReadFile(overflowFile)
if err != nil {
return "", err
}
Expand Down

0 comments on commit 726f868

Please sign in to comment.