Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove io/ioutil #4337

Merged
merged 1 commit into from
Oct 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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