Handle ioutil deprecations (#53526)
* replace ioutil.ReadFile -> os.ReadFile * replace ioutil.ReadAll -> io.ReadAll * replace ioutil.TempFile -> os.CreateTemp * replace ioutil.NopCloser -> io.NopCloser * replace ioutil.WriteFile -> os.WriteFile * replace ioutil.TempDir -> os.MkdirTemp * replace ioutil.Discard -> io.Discard
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@@ -627,7 +626,7 @@ func (s *Service) getDefaultProject(ctx context.Context, dsInfo datasourceInfo)
|
||||
}
|
||||
|
||||
func unmarshalResponse(res *http.Response) (cloudMonitoringResponse, error) {
|
||||
body, err := ioutil.ReadAll(res.Body)
|
||||
body, err := io.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
return cloudMonitoringResponse{}, err
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"regexp"
|
||||
@@ -216,7 +215,7 @@ func decode(encoding string, original io.ReadCloser) ([]byte, error) {
|
||||
return nil, fmt.Errorf("unexpected encoding type %v", err)
|
||||
}
|
||||
|
||||
body, err := ioutil.ReadAll(reader)
|
||||
body, err := io.ReadAll(reader)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
@@ -78,7 +78,7 @@ func Test_doRequest(t *testing.T) {
|
||||
t.Errorf("Unexpected headers: %v", res.Header())
|
||||
}
|
||||
result := rw.Result()
|
||||
body, err := ioutil.ReadAll(result.Body)
|
||||
body, err := io.ReadAll(result.Body)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@ package cloudmonitoring
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"net/url"
|
||||
"os"
|
||||
"strconv"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -479,7 +479,7 @@ func loadTestFile(path string) (cloudMonitoringResponse, error) {
|
||||
|
||||
// Can ignore gosec warning G304 here since it's a test path
|
||||
// nolint:gosec
|
||||
jsonBody, err := ioutil.ReadFile(path)
|
||||
jsonBody, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return data, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user