From b1961c07ac12cfd19cc69e9b6ef0dc8e6d93ca00 Mon Sep 17 00:00:00 2001 From: Ocasta Date: Wed, 15 Feb 2023 14:31:31 -0600 Subject: [PATCH] replace ioutil.ReadAll with io.ReadAll --- pkg/internal/common/json.go | 6 +++--- pkg/internal/common/util.go | 4 ++-- pkg/internal/unit21/base.go | 6 +++--- pkg/service/geofencing.go | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pkg/internal/common/json.go b/pkg/internal/common/json.go index 18c4cf56..8abc28e1 100644 --- a/pkg/internal/common/json.go +++ b/pkg/internal/common/json.go @@ -2,7 +2,7 @@ package common import ( "encoding/json" - "io/ioutil" + "io" "net/http" "reflect" "time" @@ -18,7 +18,7 @@ func GetJson(url string, target interface{}) error { return StringError(err) } defer response.Body.Close() - jsonData, err := ioutil.ReadAll(response.Body) + jsonData, err := io.ReadAll(response.Body) if err != nil { return StringError(err) } @@ -41,7 +41,7 @@ func GetJsonGeneric(url string, target interface{}) error { return StringError(err) } defer response.Body.Close() - jsonData, err := ioutil.ReadAll(response.Body) + jsonData, err := io.ReadAll(response.Body) if err != nil { return StringError(err) } diff --git a/pkg/internal/common/util.go b/pkg/internal/common/util.go index 15041d88..1139d7e7 100644 --- a/pkg/internal/common/util.go +++ b/pkg/internal/common/util.go @@ -6,7 +6,7 @@ import ( "encoding/hex" "encoding/json" "fmt" - "io/ioutil" + "io" "log" "math" "os" @@ -107,7 +107,7 @@ func BetterStringify(jsonBody any) (betterString string, err error) { bodyReader := bytes.NewReader(bodyBytes) - betterBytes, err := ioutil.ReadAll(bodyReader) + betterBytes, err := io.ReadAll(bodyReader) betterString = string(betterBytes) if err != nil { return betterString, StringError(err) diff --git a/pkg/internal/unit21/base.go b/pkg/internal/unit21/base.go index 1f0e6c89..143467f1 100644 --- a/pkg/internal/unit21/base.go +++ b/pkg/internal/unit21/base.go @@ -4,7 +4,7 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" + "io" "log" "net/http" "os" @@ -45,7 +45,7 @@ func u21Put(url string, jsonBody any) (body []byte, err error) { defer res.Body.Close() - body, err = ioutil.ReadAll(res.Body) + body, err = io.ReadAll(res.Body) if err != nil { log.Printf("Error extracting body from %s update request: %s", url, err) return nil, common.StringError(err) @@ -92,7 +92,7 @@ func u21Post(url string, jsonBody any) (body []byte, err error) { defer res.Body.Close() - body, err = ioutil.ReadAll(res.Body) + body, err = io.ReadAll(res.Body) if err != nil { log.Printf("Error extracting body from %s update response: %s", url, err) return nil, common.StringError(err) diff --git a/pkg/service/geofencing.go b/pkg/service/geofencing.go index d5b8f7b0..d6a31f7a 100644 --- a/pkg/service/geofencing.go +++ b/pkg/service/geofencing.go @@ -2,7 +2,7 @@ package service import ( "encoding/json" - "io/ioutil" + "io" "net/http" "os" @@ -95,7 +95,7 @@ func getLocationFromAPI(ip string) (GeoLocation, error) { } // read the response body - body, err := ioutil.ReadAll(res.Body) + body, err := io.ReadAll(res.Body) if err != nil { return GeoLocation{}, common.StringError(err)