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

Replace deprecated ioutil with os #46

Merged
merged 1 commit into from
Mar 31, 2024
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
5 changes: 2 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"image/draw"
"image/png"
"io/fs"
"io/ioutil"
"log"
"os"
"path/filepath"
Expand Down Expand Up @@ -64,7 +63,7 @@ func loadImageGlob(dir string, glob string) (image.Image, error) {
return nil, fmt.Errorf("file does not exist: %s", pattern)
}

data, err := ioutil.ReadFile(matches[0])
data, err := os.ReadFile(matches[0])
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -140,7 +139,7 @@ func saveImage(filename string, img image.Image) error {
if err != nil {
return err
}
return ioutil.WriteFile(filename, buf.Bytes(), 0644)
return os.WriteFile(filename, buf.Bytes(), 0644)
}

func getThemeNames() ([]string, error) {
Expand Down
5 changes: 2 additions & 3 deletions main_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"io/ioutil"
"os"
"testing"
)
Expand All @@ -17,15 +16,15 @@ func TestThemeImages(t *testing.T) {
t.Fatal("themes file is not found : ", err)
}

themedirs, err := ioutil.ReadDir(themeDir)
themedirs, err := os.ReadDir(themeDir)
if err != nil {
t.Fatal("themes file is not found : ", err)
}

for _, themedir := range themedirs {
if themedir.IsDir() {
t.Log("found theme : ", themedir.Name())
files, err := ioutil.ReadDir(themeDir + "/" + themedir.Name())
files, err := os.ReadDir(themeDir + "/" + themedir.Name())
if err != nil {
t.Log("theme image is not found. skipping,,, : ", err)
continue
Expand Down
Loading