Skip to content

Commit

Permalink
chore: remove refs to deprecated io/ioutil
Browse files Browse the repository at this point in the history
Signed-off-by: guoguangwu <guoguangwu@magic-shield.com>
  • Loading branch information
testwill committed Jun 29, 2023
1 parent 2fc0613 commit f2a7973
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 22 deletions.
15 changes: 2 additions & 13 deletions enginetest/testgen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package enginetest
import (
"bufio"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -97,12 +96,7 @@ func writePlans(t *testing.T, s [][]setup.SetupScript, original []queries.QueryP

func TestWriteComplexIndexQueries(t *testing.T) {
t.Skip()
tmp, err := ioutil.TempDir("", "*")
if err != nil {
return
}

outputPath := filepath.Join(tmp, "complex_index_queries.txt")
outputPath := filepath.Join(t.TempDir(), "complex_index_queries.txt")
f, err := os.Create(outputPath)
require.NoError(t, err)

Expand All @@ -121,12 +115,7 @@ func TestWriteComplexIndexQueries(t *testing.T) {

func TestWriteCreateTableQueries(t *testing.T) {
t.Skip()
tmp, err := ioutil.TempDir("", "*")
if err != nil {
return
}

outputPath := filepath.Join(tmp, "create_table_queries.txt")
outputPath := filepath.Join(t.TempDir(), "create_table_queries.txt")
f, err := os.Create(outputPath)
require.NoError(t, err)

Expand Down
7 changes: 3 additions & 4 deletions internal/sockstate/netstat_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"encoding/binary"
"fmt"
"io"
"io/ioutil"
"log"
"net"
"os"
Expand Down Expand Up @@ -70,7 +69,7 @@ func getProcName(s []byte) string {
func (p *procFd) iterFdDir() {
// link name is of the form socket:[5860846]
fddir := path.Join(p.base, "/fd")
fi, err := ioutil.ReadDir(fddir)
fi, err := os.ReadDir(fddir)
if err != nil {
return
}
Expand Down Expand Up @@ -110,7 +109,7 @@ func (p *procFd) iterFdDir() {

func extractProcInfo(sktab []sockTabEntry) {
const basedir = "/proc"
fi, err := ioutil.ReadDir(basedir)
fi, err := os.ReadDir(basedir)
if err != nil {
return
}
Expand Down Expand Up @@ -233,7 +232,7 @@ var isWSL = false
var isProcBlocked = false

func init() {
osRelease, err := ioutil.ReadFile("/proc/sys/kernel/osrelease")
osRelease, err := os.ReadFile("/proc/sys/kernel/osrelease")
if err == nil {
osReleaseString := strings.ToLower(string(osRelease))
if strings.Contains(osReleaseString, "microsoft") {
Expand Down
4 changes: 2 additions & 2 deletions server/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package server
import (
"context"
"fmt"
"io/ioutil"
"io"
"net"
"strconv"
"testing"
Expand Down Expand Up @@ -1182,7 +1182,7 @@ func testServer(t *testing.T, ready chan struct{}, port string, breakConn bool)
_ = conn.Close()
}()

_, err = ioutil.ReadAll(conn)
_, err = io.ReadAll(conn)
if err != nil {
t.Fatal(err)
}
Expand Down
5 changes: 2 additions & 3 deletions sql/expression/function/load_file_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package function

import (
"io/ioutil"
"os"
"testing"

Expand All @@ -16,7 +15,7 @@ import (
func createTempDirAndFile(fileName string) (string, *os.File, error) {
dir := os.TempDir()

file, err := ioutil.TempFile(dir, fileName)
file, err := os.CreateTemp(dir, fileName)
if err != nil {
return "", nil, err
}
Expand Down Expand Up @@ -107,7 +106,7 @@ func TestLoadFile(t *testing.T) {
// runLoadFileTest takes in a loadFileTestCase and its relevant directory and validates whether LOAD_FILE is reading
// the file accordingly.
func runLoadFileTest(t *testing.T, tt loadFileTestCase, dir string) {
file, err := ioutil.TempFile(dir, tt.fileName)
file, err := os.CreateTemp(dir, tt.fileName)
assert.NoError(t, err)

defer file.Close()
Expand Down

0 comments on commit f2a7973

Please sign in to comment.