From 10689143b7f8d7b34c29caee41d1e8f9ab80d318 Mon Sep 17 00:00:00 2001 From: Kashiwa Date: Sun, 31 Mar 2024 21:13:22 +0800 Subject: [PATCH] Replace deprecated ioutil with os --- main.go | 5 ++--- main_test.go | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index 8edba2a..a848ce8 100644 --- a/main.go +++ b/main.go @@ -9,7 +9,6 @@ import ( "image/draw" "image/png" "io/fs" - "io/ioutil" "log" "os" "path/filepath" @@ -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 } @@ -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) { diff --git a/main_test.go b/main_test.go index b254c27..3da87b9 100644 --- a/main_test.go +++ b/main_test.go @@ -1,7 +1,6 @@ package main import ( - "io/ioutil" "os" "testing" ) @@ -17,7 +16,7 @@ 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) } @@ -25,7 +24,7 @@ func TestThemeImages(t *testing.T) { 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