From c3cbecc4c41ef755445df21f0c5df99bbd1622ea Mon Sep 17 00:00:00 2001 From: songzhibin97 <49082129+songzhibin97@users.noreply.github.com> Date: Sat, 10 Dec 2022 11:12:22 +0800 Subject: [PATCH 1/2] fix: update ioutil func&pruning case --- util/printer.go | 2 ++ util/util.go | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/util/printer.go b/util/printer.go index 748097f91429a..56724bc1ff664 100644 --- a/util/printer.go +++ b/util/printer.go @@ -31,6 +31,7 @@ var ( ) // GetRawInfo do what its name tells +// nolint:unused func GetRawInfo(app string) string { info := "" info += fmt.Sprintf("App Name: %s\n", app) @@ -43,6 +44,7 @@ func GetRawInfo(app string) string { } // PrintInfo prints the app's basic information in log +// nolint:unused func PrintInfo(app string) { log.Info("Welcome to "+app, zap.String("Release Version", Version), diff --git a/util/util.go b/util/util.go index 0e862345f23bd..17148f2c5012a 100644 --- a/util/util.go +++ b/util/util.go @@ -18,7 +18,7 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" + "io" "net" "net/http" "strconv" @@ -26,9 +26,10 @@ import ( "time" "github.com/pingcap/errors" - "github.com/pingcap/tidb/parser" "go.uber.org/atomic" "go.uber.org/zap" + + "github.com/pingcap/tidb/parser" ) // SliceToMap converts slice to map @@ -63,6 +64,8 @@ func StringsToInterfaces(strs []string) []interface{} { // return errors.Trace(err) // } // fmt.Println(resp.IP) +// +// nolint:unused func GetJSON(client *http.Client, url string, v interface{}) error { resp, err := client.Get(url) if err != nil { @@ -71,7 +74,7 @@ func GetJSON(client *http.Client, url string, v interface{}) error { defer resp.Body.Close() if resp.StatusCode != http.StatusOK { - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return errors.Trace(err) } @@ -181,7 +184,7 @@ func GenLogFields(costTime time.Duration, info *ProcessInfo, needTruncateSQL boo // PrintableASCII detects if b is a printable ASCII character. // Ref to:http://facweb.cs.depaul.edu/sjost/it212/documents/ascii-pr.htm func PrintableASCII(b byte) bool { - if b >= 0 && b < 32 || b > 127 { + if b < 32 || b > 127 { return false } From 674369ab6f6b8484cc290454e896fb1bed945ac0 Mon Sep 17 00:00:00 2001 From: songzhibin97 <49082129+songzhibin97@users.noreply.github.com> Date: Sat, 10 Dec 2022 11:31:18 +0800 Subject: [PATCH 2/2] Update util.go --- util/util.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/util/util.go b/util/util.go index 17148f2c5012a..e3a9cf25f750f 100644 --- a/util/util.go +++ b/util/util.go @@ -26,10 +26,9 @@ import ( "time" "github.com/pingcap/errors" + "github.com/pingcap/tidb/parser" "go.uber.org/atomic" "go.uber.org/zap" - - "github.com/pingcap/tidb/parser" ) // SliceToMap converts slice to map