From aad8f7d3e2e7fae47393699819d7a584a9e2ef85 Mon Sep 17 00:00:00 2001 From: dingjun Date: Thu, 1 Sep 2022 14:40:46 +0800 Subject: [PATCH] fix static check warnings --- client_https.go | 4 ++-- config.go | 4 ++-- main.go | 6 ++---- server_https.go | 4 ++-- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/client_https.go b/client_https.go index a7b8775..ad4127e 100644 --- a/client_https.go +++ b/client_https.go @@ -4,7 +4,7 @@ import ( "bytes" "context" "fmt" - "io/ioutil" + "io" "net/http" "time" @@ -45,7 +45,7 @@ func (c *httpclient) Exchange(msg *dns.Msg, upstream string) (*dns.Msg, int, err return nil, 0, fmt.Errorf("http error %d", resp.StatusCode) } - data, err = ioutil.ReadAll(resp.Body) + data, err = io.ReadAll(resp.Body) if err != nil { return nil, 0, err } diff --git a/config.go b/config.go index 17b636a..7d2a138 100644 --- a/config.go +++ b/config.go @@ -1,7 +1,7 @@ package main import ( - "io/ioutil" + "os" "github.com/go-yaml/yaml" ) @@ -21,7 +21,7 @@ type listen struct { } func loadConfig(f string) (*conf, error) { - data, err := ioutil.ReadFile(f) + data, err := os.ReadFile(f) if err != nil { return nil, err } diff --git a/main.go b/main.go index 36e4ece..68d3410 100644 --- a/main.go +++ b/main.go @@ -61,9 +61,7 @@ func main() { makeServers(cfg) ch := make(chan os.Signal, 2) signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM) - select { - case s := <-ch: - log.Errorf("received signal %s, exit...", s) - } + s := <-ch + log.Errorf("received signal %s, exit...", s) log.Println("exit.") } diff --git a/server_https.go b/server_https.go index b18297d..6c6d6d3 100644 --- a/server_https.go +++ b/server_https.go @@ -1,7 +1,7 @@ package main import ( - "io/ioutil" + "io" "net/http" log "github.com/fangdingjun/go-log/v5" @@ -26,7 +26,7 @@ func (srv *server) handleHTTPReq(w http.ResponseWriter, r *http.Request) { return } - data, err := ioutil.ReadAll(r.Body) + data, err := io.ReadAll(r.Body) if err != nil { log.Errorln("read request body", err) http.Error(w, "read request failed", http.StatusBadRequest)