Skip to content

Commit

Permalink
chore: remove refs to deprecated io/ioutil (#796)
Browse files Browse the repository at this point in the history
  • Loading branch information
testwill authored Jul 28, 2023
1 parent 9997aa9 commit 651a63f
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 24 deletions.
13 changes: 6 additions & 7 deletions assets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package engo
import (
"bytes"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -70,7 +69,7 @@ func TestFilesLoad(t *testing.T) {
Files.Register(".test", &testLoader{})

content := []byte("testing")
dir, err := ioutil.TempDir(".", "testing")
dir, err := os.MkdirTemp(".", "testing")
if err != nil {
t.Errorf("failed to create temp directory for testing, error: %v", err)
}
Expand All @@ -80,7 +79,7 @@ func TestFilesLoad(t *testing.T) {

tmpfn := filepath.Join(dir, "test1.test")

if err = ioutil.WriteFile(tmpfn, content, 0666); err != nil {
if err = os.WriteFile(tmpfn, content, 0666); err != nil {
t.Errorf("failed to create temp file for testing, file: %v, error: %v", tmpfn, err)
}

Expand All @@ -93,7 +92,7 @@ func TestFilesMultipleLoad(t *testing.T) {
Files.Register(".test", &testLoader{})

content := []byte("testing")
dir, err := ioutil.TempDir(".", "testing")
dir, err := os.MkdirTemp(".", "testing")
if err != nil {
t.Errorf("failed to create temp directory for testing, error: %v", err)
}
Expand All @@ -103,19 +102,19 @@ func TestFilesMultipleLoad(t *testing.T) {

tmpfn := filepath.Join(dir, "test1.test")

if err = ioutil.WriteFile(tmpfn, content, 0666); err != nil {
if err = os.WriteFile(tmpfn, content, 0666); err != nil {
t.Errorf("failed to create temp file for testing, file: %v, error: %v", tmpfn, err)
}

tmpfn = filepath.Join(dir, "test2.test")

if err = ioutil.WriteFile(tmpfn, content, 0666); err != nil {
if err = os.WriteFile(tmpfn, content, 0666); err != nil {
t.Errorf("failed to create temp file for testing, file: %v, error: %v", tmpfn, err)
}

tmpfn = filepath.Join(dir, "test3.test")

if err = ioutil.WriteFile(tmpfn, content, 0666); err != nil {
if err = os.WriteFile(tmpfn, content, 0666); err != nil {
t.Errorf("failed to create temp file for testing, file: %v, error: %v", tmpfn, err)
}

Expand Down
3 changes: 1 addition & 2 deletions common/audio_filetype.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"fmt"
"io"
"io/ioutil"
"os"

"github.com/EngoEngine/engo"
Expand All @@ -21,7 +20,7 @@ type audioLoader struct {
// Load processes the data stream and parses it as an audio file
func (a *audioLoader) Load(url string, data io.Reader) error {
var err error
audioBytes, err := ioutil.ReadAll(data)
audioBytes, err := io.ReadAll(data)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions common/font.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"image"
"image/color"
"image/draw"
"io/ioutil"
"log"
"os"

"github.com/EngoEngine/engo"
"github.com/EngoEngine/gl"
Expand Down Expand Up @@ -56,7 +56,7 @@ func LoadedFont(url string, size float64, bg, fg color.Color) (*Font, error) {
// Create is for loading fonts from the disk, given a location
func (f *Font) Create() error {
// Read and parse the font
ttfBytes, err := ioutil.ReadFile(f.URL)
ttfBytes, err := os.ReadFile(f.URL)
if err != nil {
return err
}
Expand Down
3 changes: 1 addition & 2 deletions common/font_filetype.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package common
import (
"fmt"
"io"
"io/ioutil"

"github.com/EngoEngine/engo"
"github.com/golang/freetype"
Expand All @@ -29,7 +28,7 @@ type fontLoader struct {

// Load processes the data stream and parses it as a freetype font
func (i *fontLoader) Load(url string, data io.Reader) error {
ttfBytes, err := ioutil.ReadAll(data)
ttfBytes, err := io.ReadAll(data)
if err != nil {
return err
}
Expand Down
17 changes: 8 additions & 9 deletions common/tmx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"image"
"image/png"
"io/ioutil"
"os"
"path/filepath"
"testing"
Expand Down Expand Up @@ -186,7 +185,7 @@ func TestTMXTileNotLoadedTempFile(t *testing.T) {
t.Errorf("Unable to encode png from image")
}

dir, err := ioutil.TempDir(".", "testing")
dir, err := os.MkdirTemp(".", "testing")
if err != nil {
t.Errorf("failed to create temp directory for testing, error: %v", err)
}
Expand All @@ -195,7 +194,7 @@ func TestTMXTileNotLoadedTempFile(t *testing.T) {
engo.Files.SetRoot(dir)

tmpfn := filepath.Join(dir, "test.png")
if err = ioutil.WriteFile(tmpfn, imgbuf.Bytes(), 0666); err != nil {
if err = os.WriteFile(tmpfn, imgbuf.Bytes(), 0666); err != nil {
t.Errorf("failed to create temp file for testing, file: %v, error: %v", tmpfn, err)
}

Expand Down Expand Up @@ -228,7 +227,7 @@ func TestTMXTileNotLoadedTempFileBadExtensions(t *testing.T) {
t.Errorf("Unable to encode png from image")
}

dir, err := ioutil.TempDir(".", "testing")
dir, err := os.MkdirTemp(".", "testing")
if err != nil {
t.Errorf("failed to create temp directory for testing, error: %v", err)
}
Expand All @@ -237,7 +236,7 @@ func TestTMXTileNotLoadedTempFileBadExtensions(t *testing.T) {
engo.Files.SetRoot(dir)

tmpfn := filepath.Join(dir, "test.test")
if err = ioutil.WriteFile(tmpfn, imgbuf.Bytes(), 0666); err != nil {
if err = os.WriteFile(tmpfn, imgbuf.Bytes(), 0666); err != nil {
t.Errorf("failed to create temp file for testing, file: %v, error: %v", tmpfn, err)
}

Expand Down Expand Up @@ -370,7 +369,7 @@ func TestTMXTileImagesNotLoadedTempFile(t *testing.T) {
t.Errorf("Unable to encode png from image")
}

dir, err := ioutil.TempDir(".", "testing")
dir, err := os.MkdirTemp(".", "testing")
if err != nil {
t.Errorf("failed to create temp directory for testing, error: %v", err)
}
Expand All @@ -379,7 +378,7 @@ func TestTMXTileImagesNotLoadedTempFile(t *testing.T) {
engo.Files.SetRoot(dir)

tmpfn := filepath.Join(dir, "test.png")
if err = ioutil.WriteFile(tmpfn, imgbuf.Bytes(), 0666); err != nil {
if err = os.WriteFile(tmpfn, imgbuf.Bytes(), 0666); err != nil {
t.Errorf("failed to create temp file for testing, file: %v, error: %v", tmpfn, err)
}

Expand Down Expand Up @@ -479,7 +478,7 @@ func TestObjectImageNotExistTempFile(t *testing.T) {
t.Errorf("Unable to encode png from image")
}

dir, err := ioutil.TempDir(".", "testing")
dir, err := os.MkdirTemp(".", "testing")
if err != nil {
t.Errorf("failed to create temp directory for testing, error: %v", err)
}
Expand All @@ -488,7 +487,7 @@ func TestObjectImageNotExistTempFile(t *testing.T) {
engo.Files.SetRoot(dir)

tmpfn := filepath.Join(dir, "objimgtest.png")
if err = ioutil.WriteFile(tmpfn, imgbuf.Bytes(), 0666); err != nil {
if err = os.WriteFile(tmpfn, imgbuf.Bytes(), 0666); err != nil {
t.Errorf("failed to create temp file for testing, file: %v, error: %v", tmpfn, err)
}

Expand Down
3 changes: 1 addition & 2 deletions demos/assetbundling/assets/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 651a63f

Please sign in to comment.