fix: io and os instead of deprecated ioutil

Deprecated: As of Go 1.16, the same functionality is now provided by package io or package os, and those implementations should be preferred in new code. See the specific function documentation for details.
https://pkg.go.dev/io/ioutil
This commit is contained in:
GreyXor
2022-10-29 11:35:22 +02:00
parent 1b7eed5afe
commit b9bf6e80f4
6 changed files with 10 additions and 13 deletions
+2 -2
View File
@@ -27,7 +27,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"net/url"
@@ -140,7 +140,7 @@ func (c *Client) parseResponseGoogle(ctx context.Context, w dns.ResponseWriter,
}
}
body, err := ioutil.ReadAll(req.response.Body)
body, err := io.ReadAll(req.response.Body)
if err != nil {
log.Println(err)
req.reply.Rcode = dns.RcodeServerFailure
+2 -2
View File
@@ -28,7 +28,7 @@ import (
"context"
"encoding/base64"
"fmt"
"io/ioutil"
"io"
"log"
"net"
"net/http"
@@ -178,7 +178,7 @@ func (c *Client) parseResponseIETF(ctx context.Context, w dns.ResponseWriter, r
}
}
body, err := ioutil.ReadAll(req.response.Body)
body, err := io.ReadAll(req.response.Body)
if err != nil {
log.Printf("read error from upstream %s: %v\n", req.currentUpstream, err)
req.reply.Rcode = dns.RcodeServerFailure
+1 -2
View File
@@ -27,7 +27,6 @@ import (
"flag"
"fmt"
"io"
"io/ioutil"
"log"
"os"
"runtime"
@@ -40,7 +39,7 @@ func checkPIDFile(pidFile string) (bool, error) {
retry:
f, err := os.OpenFile(pidFile, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0666)
if os.IsExist(err) {
pidStr, err := ioutil.ReadFile(pidFile)
pidStr, err := os.ReadFile(pidFile)
if err != nil {
return false, err
}