Skip to content

Commit a024796

Browse files
committed
Replace deprecated io/ioutil usage
1 parent d397295 commit a024796

File tree

4 files changed

+6
-8
lines changed

4 files changed

+6
-8
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module github.com/tklauser/ps
22

3-
go 1.13
3+
go 1.16
44

55
require golang.org/x/sys v0.11.0

process_procfs_stat.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ package ps
1010
import (
1111
"bytes"
1212
"fmt"
13-
"io/ioutil"
13+
"os"
1414
"path/filepath"
1515
"strconv"
1616
"strings"
@@ -28,7 +28,7 @@ func newUnixProcess(pid int) (Process, error) {
2828
} else if err != nil {
2929
return nil, fmt.Errorf("failed to lstat %s: %w", procDir, err)
3030
}
31-
b, err := ioutil.ReadFile(filepath.Join(procDir, "stat"))
31+
b, err := os.ReadFile(filepath.Join(procDir, "stat"))
3232
if err != nil {
3333
return nil, err
3434
}
@@ -55,7 +55,7 @@ func newUnixProcess(pid int) (Process, error) {
5555
p.command = string(comm)
5656
p.executablePath, _ = filepath.EvalSymlinks(filepath.Join(procDir, "exe"))
5757

58-
b, err = ioutil.ReadFile(filepath.Join(procDir, "cmdline"))
58+
b, err = os.ReadFile(filepath.Join(procDir, "cmdline"))
5959
if err == nil && len(b) > 0 {
6060
p.executableArgs = strings.FieldsFunc(string(b), func(r rune) bool {
6161
return r == '\u0000'

process_solaris.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ package ps
77
import (
88
"encoding/binary"
99
"fmt"
10-
"io/ioutil"
1110
"os"
1211
"path/filepath"
1312
"strconv"
@@ -115,7 +114,7 @@ func newUnixProcess(pid int) (Process, error) {
115114

116115
p.executablePath, _ = filepath.EvalSymlinks(filepath.Join(procDir, "path", "a.out"))
117116

118-
b, err := ioutil.ReadFile(filepath.Join(procDir, "cmdline"))
117+
b, err := os.ReadFile(filepath.Join(procDir, "cmdline"))
119118
if err == nil && len(b) > 0 {
120119
p.executableArgs = strings.FieldsFunc(string(b), func(r rune) bool {
121120
return r == '\u0000'

process_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package ps_test
66

77
import (
88
"bytes"
9-
"io/ioutil"
109
"os"
1110
"path/filepath"
1211
"runtime"
@@ -122,7 +121,7 @@ func getInitName() string {
122121
return "init"
123122
case "linux":
124123
// might be systemd, sysv init, openrc, ...
125-
b, err := ioutil.ReadFile("/proc/1/comm")
124+
b, err := os.ReadFile("/proc/1/comm")
126125
if err == nil {
127126
return string(bytes.Trim(b, " \r\n"))
128127
}

0 commit comments

Comments
 (0)