Skip to content

Commit

Permalink
refactor: Replace use of deprecated io/ioutil to proper package.
Browse files Browse the repository at this point in the history
closes edgexfoundry#883

Signed-off-by: lenny <[email protected]>
  • Loading branch information
lenny committed Jun 10, 2021
1 parent b500d5f commit fbe9468
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions internal/trigger/http/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"context"
"errors"
"fmt"
"io/ioutil"
"io"
"net/http"
"sync"

Expand Down Expand Up @@ -73,7 +73,7 @@ func (trigger *Trigger) requestHandler(writer http.ResponseWriter, r *http.Reque

contentType := r.Header.Get(common.ContentType)

data, err := ioutil.ReadAll(r.Body)
data, err := io.ReadAll(r.Body)
if err != nil {
lc.Error("Error reading HTTP Body", "error", err)
writer.WriteHeader(http.StatusBadRequest)
Expand Down
6 changes: 3 additions & 3 deletions pkg/transforms/compression_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"compress/gzip"
"compress/zlib"
"encoding/base64"
"io/ioutil"
"io"
"testing"

"github.com/edgexfoundry/go-mod-core-contracts/v2/common"
Expand Down Expand Up @@ -50,7 +50,7 @@ func TestGzip(t *testing.T) {
zr, err := gzip.NewReader(&buf)
require.NoError(t, err)

decoded, err := ioutil.ReadAll(zr)
decoded, err := io.ReadAll(zr)
require.NoError(t, err)
require.Equal(t, clearString, string(decoded))

Expand All @@ -76,7 +76,7 @@ func TestZlib(t *testing.T) {
zr, err := zlib.NewReader(&buf)
require.NoError(t, err)

decoded, err := ioutil.ReadAll(zr)
decoded, err := io.ReadAll(zr)
require.NoError(t, err)
require.Equal(t, clearString, string(decoded))

Expand Down
4 changes: 2 additions & 2 deletions pkg/transforms/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"bytes"
"errors"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/url"

Expand Down Expand Up @@ -219,7 +219,7 @@ func (sender HTTPSender) httpSend(ctx interfaces.AppFunctionContext, data interf
}

defer func() { _ = response.Body.Close() }()
responseData, errReadingBody := ioutil.ReadAll(response.Body)
responseData, errReadingBody := io.ReadAll(response.Body)
if errReadingBody != nil {
// Can't have continueOnSendError=true when returnInputData=false, so no need to check for it here
sender.setRetryData(ctx, exportData)
Expand Down
4 changes: 2 additions & 2 deletions pkg/transforms/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package transforms

import (
"errors"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"net/url"
Expand Down Expand Up @@ -56,7 +56,7 @@ func TestHTTPPostPut(t *testing.T) {

w.WriteHeader(http.StatusOK)

readMsg, _ := ioutil.ReadAll(r.Body)
readMsg, _ := io.ReadAll(r.Body)
_ = r.Body.Close()
if strings.Compare((string)(readMsg), msgStr) != 0 {
t.Errorf("Invalid msg received %v, expected %v", readMsg, msgStr)
Expand Down

0 comments on commit fbe9468

Please sign in to comment.