Skip to content

Commit

Permalink
Merge pull request #46 from ksw2000/master
Browse files Browse the repository at this point in the history
Replace deprecated ioutil with os
  • Loading branch information
mattn authored Mar 31, 2024
2 parents cd42220 + 1068914 commit 5f57065
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
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

0 comments on commit 5f57065

Please sign in to comment.