Skip to content

Commit

Permalink
Stopo using ioutil
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacalz committed Jan 6, 2025
1 parent 5e185f9 commit c2c92d1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
9 changes: 4 additions & 5 deletions theme/adwaita_theme_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"go/format"
"image/color"
"io"
"io/ioutil"
"log"
"net/http"
"os"
Expand Down Expand Up @@ -295,7 +294,7 @@ func generateColorScheme() error {
return fmt.Errorf("failed to get page: %w", err)
}
defer reps.Body.Close()
htpage, err := ioutil.ReadAll(reps.Body)
htpage, err := io.ReadAll(reps.Body)
if err != nil {
return fmt.Errorf("failed to read body: %w", err)
}
Expand Down Expand Up @@ -409,7 +408,7 @@ func generateColorScheme() error {
if formatted, err := format.Source(buffer.Bytes()); err != nil {
return fmt.Errorf("failed to format source: %w", err)
} else {
return ioutil.WriteFile(colorSchemeOutput, formatted, 0644)
return os.WriteFile(colorSchemeOutput, formatted, 0644)
}
}

Expand All @@ -427,7 +426,7 @@ func generateIcons() error {
tarReader := tar.NewReader(resp.Body)

// extract in a temporary directory
tmpDir, err := ioutil.TempDir("", "adwaita")
tmpDir, err := os.MkdirTemp("", "adwaita")
if err != nil {
return err
}
Expand Down Expand Up @@ -508,7 +507,7 @@ func generateIcons() error {
if formatted, err := format.Source(buffer.Bytes()); err != nil {
return fmt.Errorf("error formatting source: %w", err)
} else {
return ioutil.WriteFile(iconsOutput, formatted, 0644)
return os.WriteFile(iconsOutput, formatted, 0644)
}
}

Expand Down
7 changes: 3 additions & 4 deletions widget/filetree_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package widget

import (
"io/ioutil"
"os"
"path"
"path/filepath"
Expand Down Expand Up @@ -163,15 +162,15 @@ func Test_NewFileTree(t *testing.T) {

func createTempDir(t *testing.T) string {
t.Helper()
tempDir, err := ioutil.TempDir("", "test")
tempDir, err := os.MkdirTemp("", "test")
assert.NoError(t, err)
err = os.MkdirAll(path.Join(tempDir, "A"), os.ModePerm)
assert.NoError(t, err)
err = os.MkdirAll(path.Join(tempDir, "B"), os.ModePerm)
assert.NoError(t, err)
err = ioutil.WriteFile(path.Join(tempDir, "B", "C.txt"), []byte("c"), os.ModePerm)
err = os.WriteFile(path.Join(tempDir, "B", "C.txt"), []byte("c"), os.ModePerm)
assert.NoError(t, err)
err = ioutil.WriteFile(path.Join(tempDir, "B", "D.txt"), []byte("d"), os.ModePerm)
err = os.WriteFile(path.Join(tempDir, "B", "D.txt"), []byte("d"), os.ModePerm)
assert.NoError(t, err)
return tempDir
}
4 changes: 2 additions & 2 deletions widget/gif_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package widget

import (
"io/ioutil"
"io"
"os"
"testing"
"time"
Expand Down Expand Up @@ -33,7 +33,7 @@ func TestAnimatedGif_MinSize(t *testing.T) {
f, err := os.Open("./testdata/gif/earth.gif")
assert.Nil(t, err)

r, err := ioutil.ReadAll(f)
r, err := io.ReadAll(f)
assert.Nil(t, err)

res := fyne.NewStaticResource("earth.gif", r)
Expand Down

0 comments on commit c2c92d1

Please sign in to comment.