Skip to content
Snippets Groups Projects
Commit 75d90121 authored by Florent Gluck's avatar Florent Gluck
Browse files

Replaced use of deprecated ioutil functions by modern equivalents

parent 5aa5c230
No related branches found
No related tags found
No related merge requests found
package cmdMisc package cmdMisc
import ( import (
"io/ioutil"
u "nexus-client/utils" u "nexus-client/utils"
"os"
) )
type Ls struct { type Ls struct {
...@@ -42,7 +42,7 @@ func (cmd *Ls) Run(args []string) int { ...@@ -42,7 +42,7 @@ func (cmd *Ls) Run(args []string) int {
// List files in the specified directory. // List files in the specified directory.
func (cmd *Ls) listDir(dir string) { func (cmd *Ls) listDir(dir string) {
fis, err := ioutil.ReadDir(dir) fis, err := os.ReadDir(dir)
if err != nil { if err != nil {
u.PrintlnErr("Failed reading \"" + dir + "\" directory: " + err.Error()) u.PrintlnErr("Failed reading \"" + dir + "\" directory: " + err.Error())
return return
......
...@@ -2,8 +2,8 @@ package utils ...@@ -2,8 +2,8 @@ package utils
import ( import (
"fmt" "fmt"
"io/ioutil"
"net/mail" "net/mail"
"os"
"strings" "strings"
) )
...@@ -28,7 +28,7 @@ func Str2UsbDevices(s string) []string { ...@@ -28,7 +28,7 @@ func Str2UsbDevices(s string) []string {
// Returns the content of file as a string // Returns the content of file as a string
func FileToString(file string) (string, error) { func FileToString(file string) (string, error) {
content, err := ioutil.ReadFile(file) content, err := os.ReadFile(file)
if err != nil { if err != nil {
return "", err return "", err
} }
......
...@@ -3,7 +3,6 @@ package vms ...@@ -3,7 +3,6 @@ package vms
import ( import (
"encoding/base64" "encoding/base64"
"errors" "errors"
"io/ioutil"
"math" "math"
"nexus-common/caps" "nexus-common/caps"
"nexus-common/params" "nexus-common/params"
...@@ -331,7 +330,7 @@ func (vms *VMs) prepareStartVM(vmID uuid.UUID, attachPwd string) (*osexec.Cmd, * ...@@ -331,7 +330,7 @@ func (vms *VMs) prepareStartVM(vmID uuid.UUID, attachPwd string) (*osexec.Cmd, *
pwdBase64 := base64.StdEncoding.EncodeToString([]byte(spicePwd)) pwdBase64 := base64.StdEncoding.EncodeToString([]byte(spicePwd))
content := []byte(pwdBase64) content := []byte(pwdBase64)
spicePwdFile := filepath.Join(vm.dir, vmSecretFile) 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() msg := prefix + "error creating secret file: " + err.Error()
log.Error(msg) log.Error(msg)
return nil, nil, "", 0, 0, errors.New(msg) return nil, nil, "", 0, 0, errors.New(msg)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment