From 7363c1e3337c5f0d9c70cc8af7504b3f8c092ab4 Mon Sep 17 00:00:00 2001 From: xuri Date: Thu, 13 Oct 2022 00:02:53 +0800 Subject: Go 1.16 and later required, migration of deprecation package `ioutil` - Improving performance for stream writer `SetRow` function, reduces memory usage over and speedup about 19% - Update dependencies module - Update GitHub workflow --- picture_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'picture_test.go') diff --git a/picture_test.go b/picture_test.go index d419378..e90de20 100644 --- a/picture_test.go +++ b/picture_test.go @@ -7,7 +7,7 @@ import ( _ "image/jpeg" _ "image/png" "io" - "io/ioutil" + "os" "path/filepath" "strings" "testing" @@ -19,7 +19,7 @@ import ( func BenchmarkAddPictureFromBytes(b *testing.B) { f := NewFile() - imgFile, err := ioutil.ReadFile(filepath.Join("test", "images", "excel.png")) + imgFile, err := os.ReadFile(filepath.Join("test", "images", "excel.png")) if err != nil { b.Error("unable to load image for benchmark") } @@ -42,7 +42,7 @@ func TestAddPicture(t *testing.T) { assert.NoError(t, f.AddPicture("Sheet1", "F21", filepath.Join("test", "images", "excel.jpg"), `{"x_offset": 10, "y_offset": 10, "hyperlink": "https://github.com/xuri/excelize", "hyperlink_type": "External", "positioning": "oneCell"}`)) - file, err := ioutil.ReadFile(filepath.Join("test", "images", "excel.png")) + file, err := os.ReadFile(filepath.Join("test", "images", "excel.png")) assert.NoError(t, err) // Test add picture to worksheet with autofit. @@ -114,7 +114,7 @@ func TestGetPicture(t *testing.T) { file, raw, err := f.GetPicture("Sheet1", "F21") assert.NoError(t, err) if !assert.NotEmpty(t, filepath.Join("test", file)) || !assert.NotEmpty(t, raw) || - !assert.NoError(t, ioutil.WriteFile(filepath.Join("test", file), raw, 0o644)) { + !assert.NoError(t, os.WriteFile(filepath.Join("test", file), raw, 0o644)) { t.FailNow() } @@ -148,7 +148,7 @@ func TestGetPicture(t *testing.T) { file, raw, err = f.GetPicture("Sheet1", "F21") assert.NoError(t, err) if !assert.NotEmpty(t, filepath.Join("test", file)) || !assert.NotEmpty(t, raw) || - !assert.NoError(t, ioutil.WriteFile(filepath.Join("test", file), raw, 0o644)) { + !assert.NoError(t, os.WriteFile(filepath.Join("test", file), raw, 0o644)) { t.FailNow() } @@ -180,7 +180,7 @@ func TestAddDrawingPicture(t *testing.T) { func TestAddPictureFromBytes(t *testing.T) { f := NewFile() - imgFile, err := ioutil.ReadFile("logo.png") + imgFile, err := os.ReadFile("logo.png") assert.NoError(t, err, "Unable to load logo for test") assert.NoError(t, f.AddPictureFromBytes("Sheet1", fmt.Sprint("A", 1), "", "logo", ".png", imgFile)) assert.NoError(t, f.AddPictureFromBytes("Sheet1", fmt.Sprint("A", 50), "", "logo", ".png", imgFile)) -- cgit v1.2.1