From 00dd1de244c400a6cfdcafd15e53d8411771bc24 Mon Sep 17 00:00:00 2001 From: boyamurthy <92081029+boyamurthy@users.noreply.github.com> Date: Mon, 4 Sep 2023 14:40:37 +0530 Subject: [PATCH] Updating deprecated io/util (#52) --- api/api_logging.go | 3 +-- mock/mock.go | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/api/api_logging.go b/api/api_logging.go index 34eef2c..70e00aa 100644 --- a/api/api_logging.go +++ b/api/api_logging.go @@ -21,7 +21,6 @@ import ( "encoding/base64" "fmt" "io" - "io/ioutil" "net/http" "net/http/httputil" "strings" @@ -143,7 +142,7 @@ func drainBody(b io.ReadCloser) (r1, r2 io.ReadCloser, err error) { if err = b.Close(); err != nil { return nil, b, err } - return ioutil.NopCloser(&buf), ioutil.NopCloser(bytes.NewReader(buf.Bytes())), nil + return io.NopCloser(&buf), io.NopCloser(bytes.NewReader(buf.Bytes())), nil } // dumpRequest returns the given request in its HTTP/1.x wire diff --git a/mock/mock.go b/mock/mock.go index a59f99c..5737c37 100644 --- a/mock/mock.go +++ b/mock/mock.go @@ -19,7 +19,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "os" "net/http" "path/filepath" "strconv" @@ -3270,7 +3270,7 @@ func writeError(w http.ResponseWriter, message string, httpStatus int) { // // An optional replacement map. If supplied every instance of a key in the JSON file will be replaced with the corresponding value. func returnJSONFile(directory, filename string, w http.ResponseWriter, replacements map[string]string) (jsonBytes []byte) { - jsonBytes, err := ioutil.ReadFile(filepath.Join(directory, filename)) // #nosec G20 + jsonBytes, err := os.ReadFile(filepath.Join(directory, filename)) // #nosec G20 if err != nil { log.Printf("Couldn't read %s/%s", directory, filename) if w != nil {