Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Replace use of deprecated io/ioutil with proper package #893

Merged
merged 3 commits into from
Jun 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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