diff options
author | Pablo Mazzini <pmazzini@gmail.com> | 2023-05-16 07:16:49 +0100 |
---|---|---|
committer | insomniac <insomniacslk@users.noreply.github.com> | 2023-09-06 14:29:24 +0200 |
commit | c71a6be05968c3aa1dc7bf1249e908986a71c164 (patch) | |
tree | 1fdfe51883ce3639f44515ea3889ab77c27693a9 | |
parent | 01274d66fc98a2f21229adb93909a9ea6cb7e6ca (diff) |
os instead of ioutil
-rw-r--r-- | netboot/netconf.go | 3 | ||||
-rw-r--r-- | netboot/netconf_integ_test.go | 6 |
2 files changed, 4 insertions, 5 deletions
diff --git a/netboot/netconf.go b/netboot/netconf.go index 698c0d1..6370b5d 100644 --- a/netboot/netconf.go +++ b/netboot/netconf.go @@ -3,7 +3,6 @@ package netboot import ( "errors" "fmt" - "io/ioutil" "net" "os" "strings" @@ -211,7 +210,7 @@ func ConfigureInterface(ifname string, netconf *NetConf) (err error) { if len(netconf.DNSSearchList) > 0 { resolvconf += fmt.Sprintf("search %s\n", strings.Join(netconf.DNSSearchList, " ")) } - if err = ioutil.WriteFile("/etc/resolv.conf", []byte(resolvconf), 0644); err != nil { + if err = os.WriteFile("/etc/resolv.conf", []byte(resolvconf), 0644); err != nil { return fmt.Errorf("could not write resolv.conf file %v", err) } diff --git a/netboot/netconf_integ_test.go b/netboot/netconf_integ_test.go index 099296c..a0af291 100644 --- a/netboot/netconf_integ_test.go +++ b/netboot/netconf_integ_test.go @@ -4,9 +4,9 @@ package netboot import ( "fmt" - "io/ioutil" "log" "net" + "os" "testing" "time" @@ -34,7 +34,7 @@ func TestConfigureInterface(t *testing.T) { // `NetConf.DNSServers` is set. In this test we make a backup of resolv.conf // and subsequently restore it. This is really ugly, and not safe if // multiple tests do the same. - resolvconf, err := ioutil.ReadFile("/etc/resolv.conf") + resolvconf, err := os.ReadFile("/etc/resolv.conf") if err != nil { panic(fmt.Sprintf("Failed to read /etc/resolv.conf: %v", err)) } @@ -69,7 +69,7 @@ func TestConfigureInterface(t *testing.T) { // after the test, restore the content of /etc/resolv.conf . The permissions // are used only if it didn't exist. - if err = ioutil.WriteFile("/etc/resolv.conf", resolvconf, 0644); err != nil { + if err = os.WriteFile("/etc/resolv.conf", resolvconf, 0644); err != nil { panic(fmt.Sprintf("Failed to restore /etc/resolv.conf: %v", err)) } log.Printf("Restored /etc/resolv.conf") |