diff --git a/br/pkg/storage/memstore_test.go b/br/pkg/storage/memstore_test.go index a85a2ff467fa1..3ae9a08d168bc 100644 --- a/br/pkg/storage/memstore_test.go +++ b/br/pkg/storage/memstore_test.go @@ -17,7 +17,6 @@ import ( "bytes" "context" "io" - "io/ioutil" "sync" "testing" "time" @@ -70,7 +69,7 @@ func TestMemStoreBasic(t *testing.T) { require.Nil(t, err) r2, err := store.Open(ctx, "/hello.txt") require.Nil(t, err) - fileContent, err = ioutil.ReadAll(r) + fileContent, err = io.ReadAll(r) require.Nil(t, err) require.True(t, bytes.Equal([]byte("hello world 3"), fileContent)) require.Nil(t, r.Close()) @@ -83,7 +82,7 @@ func TestMemStoreBasic(t *testing.T) { _, err = r2.Seek(5, io.SeekStart) require.Nil(t, err) - fileContent, err = ioutil.ReadAll(r2) + fileContent, err = io.ReadAll(r2) require.Nil(t, err) require.True(t, bytes.Equal([]byte(" world 3"), fileContent)) diff --git a/executor/set_test.go b/executor/set_test.go index 75b6c210146b7..c24e8226a03bf 100644 --- a/executor/set_test.go +++ b/executor/set_test.go @@ -20,7 +20,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "net/http" "strconv" "testing" @@ -1802,7 +1801,7 @@ func TestSetClusterConfig(t *testing.T) { httpCnt = 0 tk.Session().SetValue(executor.TestSetConfigHTTPHandlerKey, func(req *http.Request) (*http.Response, error) { httpCnt++ - body, err := ioutil.ReadAll(req.Body) + body, err := io.ReadAll(req.Body) require.NoError(t, err) // The `raftstore.` prefix is stripped. require.JSONEq(t, `{"server.snap-max-write-bytes-per-sec":"500MB"}`, string(body)) diff --git a/parser/consistent_test.go b/parser/consistent_test.go index e78b7f31ddddd..1acc1a58bc850 100644 --- a/parser/consistent_test.go +++ b/parser/consistent_test.go @@ -14,7 +14,7 @@ package parser import ( - "io/ioutil" + gio "io" "os" "sort" "strings" @@ -27,7 +27,7 @@ func TestKeywordConsistent(t *testing.T) { parserFilename := "parser.y" parserFile, err := os.Open(parserFilename) requires.NoError(t, err) - data, err := ioutil.ReadAll(parserFile) + data, err := gio.ReadAll(parserFile) requires.NoError(t, err) content := string(data) diff --git a/parser/format/format_test.go b/parser/format/format_test.go index 429c2c27c19d1..bc04033214cdd 100644 --- a/parser/format/format_test.go +++ b/parser/format/format_test.go @@ -15,7 +15,7 @@ package format import ( "bytes" - "io/ioutil" + "io" "strings" "testing" @@ -26,7 +26,7 @@ import ( func checkFormat(t *testing.T, f Formatter, buf *bytes.Buffer, str, expect string) { _, err := f.Format(str, 3) require.NoError(t, err) - b, err := ioutil.ReadAll(buf) + b, err := io.ReadAll(buf) require.NoError(t, err) require.Equal(t, expect, string(b)) } diff --git a/parser/reserved_words_test.go b/parser/reserved_words_test.go index f58359a7d20a3..6896167741284 100644 --- a/parser/reserved_words_test.go +++ b/parser/reserved_words_test.go @@ -28,7 +28,7 @@ import ( // needed to connect to MySQL dbsql "database/sql" - "io/ioutil" + gio "io" "os" "testing" @@ -41,7 +41,7 @@ func TestCompareReservedWordsWithMySQL(t *testing.T) { parserFilename := "parser.y" parserFile, err := os.Open(parserFilename) requires.NoError(t, err) - data, err := ioutil.ReadAll(parserFile) + data, err := gio.ReadAll(parserFile) requires.NoError(t, err) content := string(data) diff --git a/planner/core/binary_plan_test.go b/planner/core/binary_plan_test.go index 806e750d33fac..be8bf75378dc7 100644 --- a/planner/core/binary_plan_test.go +++ b/planner/core/binary_plan_test.go @@ -17,7 +17,7 @@ package core_test import ( "encoding/base64" "fmt" - "io/ioutil" + "io" "os" "regexp" "strings" @@ -521,7 +521,7 @@ func TestUnnecessaryBinaryPlanInSlowLog(t *testing.T) { tk.MustExec("drop table if exists th") tk.MustExec("set global tidb_slow_log_threshold = 1;") tk.MustExec("create table th (i int, a int,b int, c int, index (a)) partition by hash (a) partitions 100;") - slowLogBytes, err := ioutil.ReadAll(f) + slowLogBytes, err := io.ReadAll(f) require.NoError(t, err) require.NotContains(t, string(slowLogBytes), `tidb_decode_binary_plan('')`) } diff --git a/server/plan_replayer.go b/server/plan_replayer.go index 30a00e4eda112..7bfb680a756ba 100644 --- a/server/plan_replayer.go +++ b/server/plan_replayer.go @@ -16,7 +16,7 @@ package server import ( "fmt" - "io/ioutil" + "io" "net/http" "os" "path/filepath" @@ -83,7 +83,7 @@ func handleDownloadFile(handler downloadFileHandler, w http.ResponseWriter, req writeError(w, err) return } - content, err := ioutil.ReadAll(file) + content, err := io.ReadAll(file) if err != nil { writeError(w, err) return @@ -137,7 +137,7 @@ func handleDownloadFile(handler downloadFileHandler, w http.ResponseWriter, req zap.String("remote-addr", remoteAddr), zap.Int("status-code", resp.StatusCode)) continue } - content, err := ioutil.ReadAll(resp.Body) + content, err := io.ReadAll(resp.Body) if err != nil { writeError(w, err) return diff --git a/server/plan_replayer_test.go b/server/plan_replayer_test.go index 2a00bc0db04de..2f2308efdd1a9 100644 --- a/server/plan_replayer_test.go +++ b/server/plan_replayer_test.go @@ -18,7 +18,6 @@ import ( "bytes" "database/sql" "io" - "io/ioutil" "os" "path/filepath" "testing" @@ -69,7 +68,7 @@ func TestDumpPlanReplayerAPI(t *testing.T) { require.NoError(t, resp0.Body.Close()) }() - body, err := ioutil.ReadAll(resp0.Body) + body, err := io.ReadAll(resp0.Body) require.NoError(t, err) path := "/tmp/plan_replayer.zip" diff --git a/statistics/handle/dump.go b/statistics/handle/dump.go index 546916751c32d..f663ab9d726f9 100644 --- a/statistics/handle/dump.go +++ b/statistics/handle/dump.go @@ -19,7 +19,7 @@ import ( "compress/gzip" "encoding/json" "fmt" - "io/ioutil" + "io" "time" "github.com/pingcap/errors" @@ -501,7 +501,7 @@ func BlocksToJSONTable(blocks [][]byte) (*JSONTable, error) { if err := gzipReader.Close(); err != nil { return nil, err } - jsonStr, err := ioutil.ReadAll(gzipReader) + jsonStr, err := io.ReadAll(gzipReader) if err != nil { return nil, errors.Trace(err) } diff --git a/util/cpuprofile/cpuprofile_test.go b/util/cpuprofile/cpuprofile_test.go index 2d400264ede10..b20428dcf21fd 100644 --- a/util/cpuprofile/cpuprofile_test.go +++ b/util/cpuprofile/cpuprofile_test.go @@ -18,7 +18,6 @@ import ( "bytes" "context" "io" - "io/ioutil" "net" "net/http" "runtime/pprof" @@ -237,7 +236,7 @@ func TestProfileHTTPHandler(t *testing.T) { resp, err = http.Get("http://" + address + "/debug/pprof/profile?seconds=100000") require.NoError(t, err) require.Equal(t, 400, resp.StatusCode) - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) require.NoError(t, err) require.Equal(t, "profile duration exceeds server's WriteTimeout\n", string(body)) require.NoError(t, resp.Body.Close())