refactor: move from io/ioutil to io and os package (#2236)

The io/ioutil package has been deprecated as of Go 1.16, see
https://golang.org/doc/go1.16#ioutil. This commit replaces the existing
io/ioutil functions with their new definitions in io and os packages.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
Eng Zer Jun
2021-10-23 17:14:12 +05:30
committed by GitHub
parent 4344eebec0
commit 7d904a9401
39 changed files with 93 additions and 109 deletions
@@ -20,7 +20,7 @@ import (
"bytes"
"encoding/base64"
"fmt"
"io/ioutil"
"io"
"net/http"
"os"
"regexp"
@@ -354,7 +354,7 @@ func invokeTriggeredFunction(conn AzureStorageConnection, sub *AzureQueueSubscri
}
defer response.Body.Close()
body, err := ioutil.ReadAll(response.Body)
body, err := io.ReadAll(response.Body)
if err != nil {
conn.logger.Error("failed to read response body from function invocation", zap.Error(err), zap.String("function_url", sub.functionURL))
continue
+3 -3
View File
@@ -20,14 +20,14 @@ import (
"crypto/tls"
"crypto/x509"
"fmt"
"io/ioutil"
"io"
"net/http"
"os"
"regexp"
"strconv"
"strings"
sarama "github.com/Shopify/sarama"
"github.com/Shopify/sarama"
cluster "github.com/bsm/sarama-cluster"
"github.com/pkg/errors"
"go.uber.org/zap"
@@ -307,7 +307,7 @@ func kafkaMsgHandler(kafka *Kafka, producer sarama.SyncProducer, trigger *fv1.Me
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
kafka.logger.Debug("got response from function invocation",
zap.String("function_url", url),
+2 -2
View File
@@ -19,7 +19,7 @@ package nats
import (
"bytes"
"fmt"
"io/ioutil"
"io"
"net/http"
"os"
"strings"
@@ -192,7 +192,7 @@ func msgHandler(nats *Nats, trigger *fv1.MessageQueueTrigger) func(*ns.Msg) {
defer resp.Body.Close()
body, bodyErr := ioutil.ReadAll(resp.Body)
body, bodyErr := io.ReadAll(resp.Body)
if bodyErr != nil {
nats.logger.Error("error reading function invocation response",
zap.Error(err),