From 86fc600806a6949c0f22f4e729990a09a8744187 Mon Sep 17 00:00:00 2001 From: Bin <49082129+songzhibin97@users.noreply.github.com> Date: Sat, 10 Dec 2022 15:33:41 +0800 Subject: [PATCH] fix: update ioutil func&pruning case (#39798) --- util/printer.go | 2 ++ util/util.go | 8 +++++--- 2 files changed, 7 insertions(+), 3 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..e3a9cf25f750f 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" @@ -63,6 +63,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 +73,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 +183,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 }