Skip to content

Commit

Permalink
deps: remove io/ioutil
Browse files Browse the repository at this point in the history
io/ioutil has been deprected since go 1.16
https://pkg.go.dev/io/ioutil

Signed-off-by: ginglis13 <[email protected]>
  • Loading branch information
ginglis13 committed Oct 13, 2023
1 parent 4baeed8 commit 1cefb25
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
3 changes: 1 addition & 2 deletions src/engine/image_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package engine

import (
"io/ioutil" //nolint:staticcheck,nolintlint
"os"
"path/filepath"
"testing"
Expand Down Expand Up @@ -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
}
Expand Down
3 changes: 1 addition & 2 deletions src/font/install_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package font

import (
"io/ioutil" //nolint:staticcheck,nolintlint
"os"
"path"
"strings"
Expand All @@ -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)
}
9 changes: 4 additions & 5 deletions src/platform/battery/battery_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ package battery
import (
"errors"
"fmt"
"io/ioutil" //nolint:staticcheck,nolintlint
"os"
"path/filepath"
"strconv"
Expand All @@ -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
}
Expand All @@ -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
}
Expand Down Expand Up @@ -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")
}
Expand Down

0 comments on commit 1cefb25

Please sign in to comment.