refactor: move from io/ioutil to io and os package
The io/ioutil package has been deprecated as of Go 1.16, see https://golang.org/doc/go1.16#ioutil. This commit replaces the existing io/ioutil functions with their new definitions in io and os packages. Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
@@ -17,7 +17,6 @@
|
||||
package ioutil
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"sort"
|
||||
"strconv"
|
||||
@@ -69,7 +68,7 @@ func TestSerialWriteCloser(t *testing.T) {
|
||||
testData[i] = []byte(repeatNumber(i, dataLen) + "\n")
|
||||
}
|
||||
|
||||
f, err := ioutil.TempFile("", "serial-write-closer")
|
||||
f, err := os.CreateTemp("", "serial-write-closer")
|
||||
require.NoError(t, err)
|
||||
defer os.RemoveAll(f.Name())
|
||||
defer f.Close()
|
||||
@@ -91,7 +90,7 @@ func TestSerialWriteCloser(t *testing.T) {
|
||||
wc.Close()
|
||||
|
||||
// Check test result
|
||||
content, err := ioutil.ReadFile(f.Name())
|
||||
content, err := os.ReadFile(f.Name())
|
||||
require.NoError(t, err)
|
||||
resultData := strings.Split(strings.TrimSpace(string(content)), "\n")
|
||||
require.Len(t, resultData, goroutine)
|
||||
|
||||
Reference in New Issue
Block a user