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.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'picture.go') diff --git a/picture.go b/picture.go index aceb3f4..05e4a51 100644 --- a/picture.go +++ b/picture.go @@ -17,7 +17,6 @@ import ( "encoding/xml" "image" "io" - "io/ioutil" "os" "path" "path/filepath" @@ -115,7 +114,7 @@ func (f *File) AddPicture(sheet, cell, picture, format string) error { if !ok { return ErrImgExt } - file, _ := ioutil.ReadFile(filepath.Clean(picture)) + file, _ := os.ReadFile(filepath.Clean(picture)) _, name := filepath.Split(picture) return f.AddPictureFromBytes(sheet, cell, format, name, ext, file) } @@ -129,7 +128,7 @@ func (f *File) AddPicture(sheet, cell, picture, format string) error { // import ( // "fmt" // _ "image/jpeg" -// "io/ioutil" +// "os" // // "github.com/xuri/excelize/v2" // ) @@ -137,7 +136,7 @@ func (f *File) AddPicture(sheet, cell, picture, format string) error { // func main() { // f := excelize.NewFile() // -// file, err := ioutil.ReadFile("image.jpg") +// file, err := os.ReadFile("image.jpg") // if err != nil { // fmt.Println(err) // } @@ -486,7 +485,7 @@ func (f *File) getSheetRelationshipsTargetByID(sheet, rID string) string { // fmt.Println(err) // return // } -// if err := ioutil.WriteFile(file, raw, 0644); err != nil { +// if err := os.WriteFile(file, raw, 0644); err != nil { // fmt.Println(err) // } func (f *File) GetPicture(sheet, cell string) (string, []byte, error) { -- cgit v1.2.1