Skip to content

Commit 9e0c817

Browse files
thaJeztahjeffwidman
authored andcommitted
go.mod: update minimum version to go1.17
golang.org/x/sys now requires go1.17 as a minimum, and otherwise fails: Error: ../../../go/pkg/mod/golang.org/x/[email protected]/unix/syscall.go:83:16: undefined: unsafe.Slice Error: ../../../go/pkg/mod/golang.org/x/[email protected]/unix/syscall_linux.go:2256:9: undefined: unsafe.Slice Error: ../../../go/pkg/mod/golang.org/x/[email protected]/unix/syscall_unix.go:118:7: undefined: unsafe.Slice Error: ../../../go/pkg/mod/golang.org/x/[email protected]/unix/sysvshm_unix.go:33:7: undefined: unsafe.Slice unsafe.Slice was added in go1.17; https://pkg.go.dev/unsafe#Slice Now that go1.17 is the minimum version, we cal also replace the deprecated io/ioutil package (which was deprecated in go1.16). Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent a33d97b commit 9e0c817

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module github.com/vishvananda/netns
22

3-
go 1.12
3+
go 1.17
44

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

netns_linux.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package netns
22

33
import (
44
"fmt"
5-
"io/ioutil"
65
"os"
76
"path"
87
"path/filepath"
@@ -136,7 +135,7 @@ func GetFromDocker(id string) (NsHandle, error) {
136135

137136
// borrowed from docker/utils/utils.go
138137
func findCgroupMountpoint(cgroupType string) (int, string, error) {
139-
output, err := ioutil.ReadFile("/proc/mounts")
138+
output, err := os.ReadFile("/proc/mounts")
140139
if err != nil {
141140
return -1, "", err
142141
}
@@ -166,7 +165,7 @@ func findCgroupMountpoint(cgroupType string) (int, string, error) {
166165
// borrowed from docker/utils/utils.go
167166
// modified to get the docker pid instead of using /proc/self
168167
func getDockerCgroup(cgroupVer int, cgroupType string) (string, error) {
169-
dockerpid, err := ioutil.ReadFile("/var/run/docker.pid")
168+
dockerpid, err := os.ReadFile("/var/run/docker.pid")
170169
if err != nil {
171170
return "", err
172171
}
@@ -178,7 +177,7 @@ func getDockerCgroup(cgroupVer int, cgroupType string) (string, error) {
178177
if err != nil {
179178
return "", err
180179
}
181-
output, err := ioutil.ReadFile(fmt.Sprintf("/proc/%d/cgroup", pid))
180+
output, err := os.ReadFile(fmt.Sprintf("/proc/%d/cgroup", pid))
182181
if err != nil {
183182
return "", err
184183
}
@@ -265,7 +264,7 @@ func getPidForContainer(id string) (int, error) {
265264
return pid, fmt.Errorf("Unable to find container: %v", id[:len(id)-1])
266265
}
267266

268-
output, err := ioutil.ReadFile(filename)
267+
output, err := os.ReadFile(filename)
269268
if err != nil {
270269
return pid, err
271270
}

0 commit comments

Comments
 (0)