From 75d901213fb6effd2ac7a929870074c1286263be Mon Sep 17 00:00:00 2001 From: Florent <florent.gluck@hesge.ch> Date: Wed, 1 Jan 2025 21:01:42 +0100 Subject: [PATCH] Replaced use of deprecated ioutil functions by modern equivalents --- src/client/cmdMisc/ls.go | 4 ++-- src/libclient/utils/strings.go | 4 ++-- src/server/vms/vms.go | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/client/cmdMisc/ls.go b/src/client/cmdMisc/ls.go index d220234..ebcc84e 100644 --- a/src/client/cmdMisc/ls.go +++ b/src/client/cmdMisc/ls.go @@ -1,8 +1,8 @@ package cmdMisc import ( - "io/ioutil" u "nexus-client/utils" + "os" ) type Ls struct { @@ -42,7 +42,7 @@ func (cmd *Ls) Run(args []string) int { // List files in the specified directory. func (cmd *Ls) listDir(dir string) { - fis, err := ioutil.ReadDir(dir) + fis, err := os.ReadDir(dir) if err != nil { u.PrintlnErr("Failed reading \"" + dir + "\" directory: " + err.Error()) return diff --git a/src/libclient/utils/strings.go b/src/libclient/utils/strings.go index 854d186..fa9547a 100644 --- a/src/libclient/utils/strings.go +++ b/src/libclient/utils/strings.go @@ -2,8 +2,8 @@ package utils import ( "fmt" - "io/ioutil" "net/mail" + "os" "strings" ) @@ -28,7 +28,7 @@ func Str2UsbDevices(s string) []string { // Returns the content of file as a string func FileToString(file string) (string, error) { - content, err := ioutil.ReadFile(file) + content, err := os.ReadFile(file) if err != nil { return "", err } diff --git a/src/server/vms/vms.go b/src/server/vms/vms.go index 72144d4..52ba181 100644 --- a/src/server/vms/vms.go +++ b/src/server/vms/vms.go @@ -3,7 +3,6 @@ package vms import ( "encoding/base64" "errors" - "io/ioutil" "math" "nexus-common/caps" "nexus-common/params" @@ -331,7 +330,7 @@ func (vms *VMs) prepareStartVM(vmID uuid.UUID, attachPwd string) (*osexec.Cmd, * pwdBase64 := base64.StdEncoding.EncodeToString([]byte(spicePwd)) content := []byte(pwdBase64) spicePwdFile := filepath.Join(vm.dir, vmSecretFile) - if err := ioutil.WriteFile(spicePwdFile, content, 0600); err != nil { + if err := os.WriteFile(spicePwdFile, content, 0600); err != nil { msg := prefix + "error creating secret file: " + err.Error() log.Error(msg) return nil, nil, "", 0, 0, errors.New(msg) -- GitLab