From d079e0bcb348237d9f88a64815fa253be0029f09 Mon Sep 17 00:00:00 2001 From: Geoffrey Teale Date: Mon, 18 Nov 2024 19:10:50 +0100 Subject: [PATCH] Remove deprecated ioutil calls --- diskv.go | 3 +-- file_test.go | 5 ++--- lib.go | 3 +-- sheet_test.go | 4 ++-- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/diskv.go b/diskv.go index bd219014..98f0d678 100644 --- a/diskv.go +++ b/diskv.go @@ -5,7 +5,6 @@ import ( "encoding/binary" "errors" "fmt" - "io/ioutil" "math" "os" "strings" @@ -353,7 +352,7 @@ func NewDiskVCellStore() (CellStore, error) { buf: bytes.NewBuffer([]byte{}), } - dir, err := ioutil.TempDir("", cellStorePrefix+generator.Hex128()) + dir, err := os.MkdirTemp("", cellStorePrefix+generator.Hex128()) if err != nil { return nil, err } diff --git a/file_test.go b/file_test.go index ade72bc7..e749f8a8 100644 --- a/file_test.go +++ b/file_test.go @@ -3,7 +3,6 @@ package xlsx import ( "encoding/xml" "io" - "io/ioutil" "os" "path/filepath" "testing" @@ -874,7 +873,7 @@ func TestFile(t *testing.T) { // We can save a File as a valid XLSX file at a given path. csRunO(c, "TestSaveFile", func(c *qt.C, option FileOption) { - tmpPath, err := ioutil.TempDir("", "testsavefile") + tmpPath, err := os.MkdirTemp("", "testsavefile") c.Assert(err, qt.IsNil) defer os.RemoveAll(tmpPath) f := NewFile(option) @@ -970,7 +969,7 @@ func TestFile(t *testing.T) { // We can save a File as a valid XLSX file at a given path. csRunO(c, "TestSaveFileWithHyperlinks", func(c *qt.C, option FileOption) { - tmpPath, err := ioutil.TempDir("", "testsavefilewithhyperlinks") + tmpPath, err := os.MkdirTemp("", "testsavefilewithhyperlinks") c.Assert(err, qt.IsNil) defer os.RemoveAll(tmpPath) f := NewFile(option) diff --git a/lib.go b/lib.go index 92cec419..7e40a0e1 100644 --- a/lib.go +++ b/lib.go @@ -7,7 +7,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "path" "path/filepath" "regexp" @@ -1281,7 +1280,7 @@ func truncateSheetXML(r io.Reader, rowLimit int) (io.Reader, error) { // When sheets are truncated, most of formatting present will be not right, but all of this formatting // is related to printing and visibility, and is out of scope for most purposes of this library. func truncateSheetXMLValueOnly(r io.Reader) (io.Reader, error) { - sheetXML, err := ioutil.ReadAll(r) + sheetXML, err := io.ReadAll(r) if err != nil { return nil, err } diff --git a/sheet_test.go b/sheet_test.go index a3485982..39cd4176 100644 --- a/sheet_test.go +++ b/sheet_test.go @@ -4,7 +4,7 @@ import ( "archive/zip" "bytes" "encoding/xml" - "io/ioutil" + "io" "path/filepath" "strings" "testing" @@ -421,7 +421,7 @@ func TestSheet(t *testing.T) { if f.Name == "xl/styles.xml" { rc, err := f.Open() c.Assert(err, qt.Equals, nil) - obtained, err = ioutil.ReadAll(rc) + obtained, err = io.ReadAll(rc) c.Assert(err, qt.Equals, nil) } }