mirror of
https://github.com/shirou/gopsutil.git
synced 2025-04-28 13:48:49 +08:00
[net][linux] Fix #1198 "f.ReadDir undefined" on Go 1.15 by redefining a custom readDir according to go version
Using os.File.Readdir pre Go 1.16 and os.File.ReadDir post Go 1.16
This commit is contained in:
parent
2f8da0a394
commit
d826e14e27
@ -549,7 +549,7 @@ func getProcInodes(root string, pid int32, max int) (map[string][]inodeMap, erro
|
|||||||
return ret, err
|
return ret, err
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
dirEntries, err := f.ReadDir(max)
|
dirEntries, err := readDir(f, max)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ret, err
|
return ret, err
|
||||||
}
|
}
|
||||||
|
12
net/net_linux_111.go
Normal file
12
net/net_linux_111.go
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
//go:build !go1.16
|
||||||
|
// +build !go1.16
|
||||||
|
|
||||||
|
package net
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
func readDir(f *os.File, max int) ([]os.FileInfo, error) {
|
||||||
|
return f.Readdir(max)
|
||||||
|
}
|
12
net/net_linux_116.go
Normal file
12
net/net_linux_116.go
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
//go:build go1.16
|
||||||
|
// +build go1.16
|
||||||
|
|
||||||
|
package net
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
func readDir(f *os.File, max int) ([]os.DirEntry, error) {
|
||||||
|
return f.ReadDir(max)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user