replace deprecated functions

This commit is contained in:
Louis Abel 2024-06-09 20:27:38 -07:00
parent 1fe2f9d2a3
commit 4ac60f8a74
Signed by: label
GPG Key ID: 3331F061D1D9990E
3 changed files with 7 additions and 8 deletions

View File

@ -3,7 +3,7 @@ package paste
import (
"fmt"
"io/ioutil"
"io"
"os"
"github.com/rocky-linux/rpaste/modules/utility"
@ -43,7 +43,7 @@ func runPaste(ctx *cli.Context) error {
if stdMethod && PasteData == "" {
fio, err := os.Stdin.Stat()
if (fio.Mode() & os.ModeCharDevice) == 0 {
bytes, _ := ioutil.ReadAll(os.Stdin)
bytes, _ := io.ReadAll(os.Stdin)
PasteData = string(bytes)
} else if err != nil {
fmt.Printf("Could not read from stdin: (%s)\n", err)
@ -65,7 +65,7 @@ func runPaste(ctx *cli.Context) error {
checkfile, _ := utility.IsFile(lastArg)
// if it's a file, send it to the PasteData var
if checkfile {
fileBytes, err := ioutil.ReadFile(lastArg)
fileBytes, err := os.ReadFile(lastArg)
if err != nil {
panic(err)
}

View File

@ -3,7 +3,7 @@ package paste
import (
"bytes"
"io/ioutil"
"os"
"os/exec"
"regexp"
"strconv"
@ -96,14 +96,14 @@ func cpuInfo() string {
func support64Bit() string {
text := " lm "
file, _ := ioutil.ReadFile("/proc/cpuinfo")
file, _ := os.ReadFile("/proc/cpuinfo")
string := string(file)
return strconv.FormatBool(strings.Contains(string, text))
}
func virtSupport() string {
re, _ := regexp.Compile(`(vmx|svm)`)
file, _ := ioutil.ReadFile("/proc/cpuinfo")
file, _ := os.ReadFile("/proc/cpuinfo")
exists := re.Match(file)
return strconv.FormatBool(exists)
}

View File

@ -5,7 +5,6 @@ package utility
import (
_ "errors"
"io/ioutil"
"os"
_ "path"
_ "path/filepath"
@ -38,7 +37,7 @@ func IsExist(path string) (bool, error) {
// Reads one-line text files (like for /sys or /proc) - Strips carriage returns
func Slurp(path string) string {
data, err := ioutil.ReadFile(path)
data, err := os.ReadFile(path)
if err != nil {
return ""
}