From 99b71c83cc3fc81cf4c65cd557ccc79def0e6038 Mon Sep 17 00:00:00 2001 From: Vamsikrishna_Siddu Date: Mon, 14 Aug 2023 02:24:38 -0400 Subject: [PATCH] remove deprecated io/ioutil package reference from goscaleio. --- api.go | 4 ++-- api/api_logging.go | 3 +-- api_test.go | 3 +-- volume.go | 4 ++-- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/api.go b/api.go index e3abbd7..1bc98bb 100644 --- a/api.go +++ b/api.go @@ -18,7 +18,7 @@ import ( "encoding/base64" "errors" "fmt" - "io/ioutil" + "io" "math" "net/http" "os" @@ -219,7 +219,7 @@ func (c *Client) getJSONWithRetry( } func extractString(resp *http.Response) (string, error) { - bs, err := ioutil.ReadAll(resp.Body) + bs, err := io.ReadAll(resp.Body) if err != nil { return "", errBodyRead } diff --git a/api/api_logging.go b/api/api_logging.go index 32dc896..e8f012c 100644 --- a/api/api_logging.go +++ b/api/api_logging.go @@ -18,7 +18,6 @@ import ( "context" "fmt" "io" - "io/ioutil" "net/http" "net/http/httputil" "strings" @@ -146,7 +145,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 } func dumpRequest(req *http.Request, body bool) ([]byte, error) { diff --git a/api_test.go b/api_test.go index a9d1ed5..648d447 100644 --- a/api_test.go +++ b/api_test.go @@ -16,7 +16,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "math" "net/http" "net/http/httptest" @@ -305,7 +304,7 @@ func testBuildError(code int) error { func testReadAll(t *testing.T, rc io.ReadCloser) []byte { t.Helper() - b, err := ioutil.ReadAll(rc) + b, err := io.ReadAll(rc) if err != nil { t.Fatal(err) } diff --git a/volume.go b/volume.go index bc9bd5e..b8c833c 100644 --- a/volume.go +++ b/volume.go @@ -15,8 +15,8 @@ package goscaleio import ( "errors" "fmt" - "io/ioutil" "net/http" + "os" "path/filepath" "regexp" "sort" @@ -161,7 +161,7 @@ func getVolumeMapping(sysID string, volID string) (mappedVolumes []*SdcMappedVol mappedVolumesMap := make(map[string]*SdcMappedVolume) diskIDPath := FSDevDirectoryPrefix + "/dev/disk/by-id" - files, _ := ioutil.ReadDir(diskIDPath) + files, _ := os.ReadDir(diskIDPath) strRegex := fmt.Sprintf(`^emc-vol-%s-%s$`, sysID, volID) r, _ := regexp.Compile(strRegex) for _, f := range files {