refactor: remove io/ioutil

io/ioutil has been deprected since go 1.16
https://pkg.go.dev/io/ioutil

Signed-off-by: ginglis13 <ginglis05@gmail.com>
This commit is contained in:
ginglis13 2023-10-12 23:37:33 -07:00 committed by Jan De Dobbeleer
parent fb5744985b
commit eef39eff77
3 changed files with 6 additions and 9 deletions

View file

@ -1,7 +1,6 @@
package engine package engine
import ( import (
"io/ioutil" //nolint:staticcheck,nolintlint
"os" "os"
"path/filepath" "path/filepath"
"testing" "testing"
@ -29,7 +28,7 @@ var cases = []struct {
func runImageTest(config, content string) (string, error) { func runImageTest(config, content string) (string, error) {
poshImagePath := "jandedobbeleer.png" poshImagePath := "jandedobbeleer.png"
file, err := ioutil.TempFile("", poshImagePath) file, err := os.CreateTemp("", poshImagePath)
if err != nil { if err != nil {
return "", err return "", err
} }

View file

@ -5,7 +5,6 @@
package font package font
import ( import (
"io/ioutil" //nolint:staticcheck,nolintlint
"os" "os"
"path" "path"
"strings" "strings"
@ -27,5 +26,5 @@ func install(font *Font, _ bool) error {
return err return err
} }
return ioutil.WriteFile(fullPath, font.Data, 0644) return os.WriteFile(fullPath, font.Data, 0644)
} }

View file

@ -24,7 +24,6 @@ package battery
import ( import (
"errors" "errors"
"fmt" "fmt"
"io/ioutil" //nolint:staticcheck,nolintlint
"os" "os"
"path/filepath" "path/filepath"
"strconv" "strconv"
@ -43,7 +42,7 @@ func newState(name string) (State, error) {
} }
func readFloat(path, filename string) (float64, error) { func readFloat(path, filename string) (float64, error) {
str, err := ioutil.ReadFile(filepath.Join(path, filename)) str, err := os.ReadFile(filepath.Join(path, filename))
if err != nil { if err != nil {
return 0, err return 0, err
} }
@ -66,12 +65,12 @@ func readAmp(path, filename string, volts float64) (float64, error) {
} }
func isBattery(path string) bool { func isBattery(path string) bool {
t, err := ioutil.ReadFile(filepath.Join(path, "type")) t, err := os.ReadFile(filepath.Join(path, "type"))
return err == nil && string(t) == "Battery\n" return err == nil && string(t) == "Battery\n"
} }
func getBatteryFiles() ([]string, error) { func getBatteryFiles() ([]string, error) {
files, err := ioutil.ReadDir(sysfs) files, err := os.ReadDir(sysfs)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -119,7 +118,7 @@ func getByPath(path string) (*battery, error) {
} }
} }
state, err := ioutil.ReadFile(filepath.Join(path, "status")) state, err := os.ReadFile(filepath.Join(path, "status"))
if err != nil || len(state) == 0 { if err != nil || len(state) == 0 {
return nil, errors.New("unable to parse or invalid status") return nil, errors.New("unable to parse or invalid status")
} }