aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/host/machine_info_linux.go
diff options
context:
space:
mode:
authorTaras Madan <tarasmadan@google.com>2023-02-23 14:28:18 +0100
committerGitHub <noreply@github.com>2023-02-23 14:28:18 +0100
commit4359978ef22a22ddd5a19adf18cbc80cb44244fb (patch)
tree7952da94e27417b39ddf952d9e0bab431dafc4c5 /pkg/host/machine_info_linux.go
parent9e2ebb3c174f1e168bc1fbadd5f02f2e25e314fc (diff)
all: ioutil is deprecated in go1.19 (#3718)
Diffstat (limited to 'pkg/host/machine_info_linux.go')
-rw-r--r--pkg/host/machine_info_linux.go9
1 files changed, 4 insertions, 5 deletions
diff --git a/pkg/host/machine_info_linux.go b/pkg/host/machine_info_linux.go
index fb05382ba..fc3664c42 100644
--- a/pkg/host/machine_info_linux.go
+++ b/pkg/host/machine_info_linux.go
@@ -7,7 +7,6 @@ import (
"bufio"
"bytes"
"fmt"
- "io/ioutil"
"os"
"path/filepath"
"regexp"
@@ -86,7 +85,7 @@ func allEqual(slice []string) bool {
}
func readKVMInfo(buffer *bytes.Buffer) error {
- files, err := ioutil.ReadDir("/sys/module/")
+ files, err := os.ReadDir("/sys/module/")
if err != nil {
return err
}
@@ -98,7 +97,7 @@ func readKVMInfo(buffer *bytes.Buffer) error {
}
paramPath := filepath.Join("/sys", "module", name, "parameters")
- params, err := ioutil.ReadDir(paramPath)
+ params, err := os.ReadDir(paramPath)
if err != nil {
if os.IsNotExist(err) {
continue
@@ -113,7 +112,7 @@ func readKVMInfo(buffer *bytes.Buffer) error {
fmt.Fprintf(buffer, "/sys/module/%s:\n", name)
for _, key := range params {
keyName := key.Name()
- data, err := ioutil.ReadFile(filepath.Join(paramPath, keyName))
+ data, err := os.ReadFile(filepath.Join(paramPath, keyName))
if err != nil {
return err
}
@@ -127,7 +126,7 @@ func readKVMInfo(buffer *bytes.Buffer) error {
func getModulesInfo() ([]KernelModule, error) {
var modules []KernelModule
- modulesText, _ := ioutil.ReadFile("/proc/modules")
+ modulesText, _ := os.ReadFile("/proc/modules")
re := regexp.MustCompile(`(\w+) .*(0[x|X][a-fA-F0-9]+)[^\n]*`)
for _, m := range re.FindAllSubmatch(modulesText, -1) {
addr, err := strconv.ParseUint(string(m[2]), 0, 64)