From eef39eff7718327bdaa43a8426ab46374b9eafa0 Mon Sep 17 00:00:00 2001 From: ginglis13 Date: Thu, 12 Oct 2023 23:37:33 -0700 Subject: [PATCH] refactor: remove io/ioutil io/ioutil has been deprected since go 1.16 https://pkg.go.dev/io/ioutil Signed-off-by: ginglis13 --- src/engine/image_test.go | 3 +-- src/font/install_unix.go | 3 +-- src/platform/battery/battery_linux.go | 9 ++++----- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/engine/image_test.go b/src/engine/image_test.go index acebd3c6..54024bc6 100644 --- a/src/engine/image_test.go +++ b/src/engine/image_test.go @@ -1,7 +1,6 @@ package engine import ( - "io/ioutil" //nolint:staticcheck,nolintlint "os" "path/filepath" "testing" @@ -29,7 +28,7 @@ var cases = []struct { func runImageTest(config, content string) (string, error) { poshImagePath := "jandedobbeleer.png" - file, err := ioutil.TempFile("", poshImagePath) + file, err := os.CreateTemp("", poshImagePath) if err != nil { return "", err } diff --git a/src/font/install_unix.go b/src/font/install_unix.go index 171c22b7..8ca43666 100644 --- a/src/font/install_unix.go +++ b/src/font/install_unix.go @@ -5,7 +5,6 @@ package font import ( - "io/ioutil" //nolint:staticcheck,nolintlint "os" "path" "strings" @@ -27,5 +26,5 @@ func install(font *Font, _ bool) error { return err } - return ioutil.WriteFile(fullPath, font.Data, 0644) + return os.WriteFile(fullPath, font.Data, 0644) } diff --git a/src/platform/battery/battery_linux.go b/src/platform/battery/battery_linux.go index 77f8f3b9..a2244d8a 100644 --- a/src/platform/battery/battery_linux.go +++ b/src/platform/battery/battery_linux.go @@ -24,7 +24,6 @@ package battery import ( "errors" "fmt" - "io/ioutil" //nolint:staticcheck,nolintlint "os" "path/filepath" "strconv" @@ -43,7 +42,7 @@ func newState(name string) (State, 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 { return 0, err } @@ -66,12 +65,12 @@ func readAmp(path, filename string, volts float64) (float64, error) { } 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" } func getBatteryFiles() ([]string, error) { - files, err := ioutil.ReadDir(sysfs) + files, err := os.ReadDir(sysfs) if err != nil { 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 { return nil, errors.New("unable to parse or invalid status") }