Replace deprecated method calls

This commit is contained in:
Kevin Cotugno 2024-03-05 07:20:15 -07:00
parent 8e0a9fe9e7
commit b8b5dd1bcd

View File

@ -6,17 +6,18 @@ import (
"flag" "flag"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"strings" "strings"
) )
var help bool var (
var cmd string help bool
var group string cmd string
var execargs []string group string
execargs []string
)
var secretsFile string var secretsFile string
@ -63,12 +64,12 @@ func system(command string, pipe bool, args ...string) (string, string, error) {
} }
if !pipe { if !pipe {
stdout, err = ioutil.ReadAll(stdoutPipe) stdout, err = io.ReadAll(stdoutPipe)
if err != nil { if err != nil {
return "", "", err return "", "", err
} }
stderr, err = ioutil.ReadAll(stderrPipe) stderr, err = io.ReadAll(stderrPipe)
if err != nil { if err != nil {
return "", "", err return "", "", err
} }
@ -202,7 +203,7 @@ func wrap() {
insertEnvironment(parseEnvironment(decrypt())) insertEnvironment(parseEnvironment(decrypt()))
_, _, err := system(execargs[0], true, execargs[1:len(execargs)]...) _, _, err := system(execargs[0], true, execargs[1:]...)
if err != nil { if err != nil {
fmt.Fprintln(os.Stderr, "Error executing external command: ", err) fmt.Fprintln(os.Stderr, "Error executing external command: ", err)
} }
@ -244,12 +245,12 @@ func editFile(file string) error {
func copyFile(oldpath, newpath string) error { func copyFile(oldpath, newpath string) error {
err := os.Rename(oldpath, newpath) err := os.Rename(oldpath, newpath)
if err != nil { if err != nil {
byteArr, err2 := ioutil.ReadFile(oldpath) byteArr, err2 := os.ReadFile(oldpath)
if err2 != nil { if err2 != nil {
return err2 return err2
} }
err2 = ioutil.WriteFile(newpath, byteArr, mode) err2 = os.WriteFile(newpath, byteArr, mode)
if err2 == nil { if err2 == nil {
_ = os.Remove(oldpath) _ = os.Remove(oldpath)
} else { } else {