diff --git a/examples/debug.go b/examples/debug.go index 2d630925e7a..16e1684dd0a 100644 --- a/examples/debug.go +++ b/examples/debug.go @@ -8,7 +8,6 @@ import ( "bytes" "fmt" "io" - "io/ioutil" "net/http" "os" ) @@ -22,11 +21,11 @@ func (t *logTransport) RoundTrip(req *http.Request) (*http.Response, error) { os.Stdout.Write([]byte("\n[request]\n")) if req.Body != nil { - req.Body = ioutil.NopCloser(&readButCopy{req.Body, &buf}) + req.Body = io.NopCloser(&readButCopy{req.Body, &buf}) } req.Write(os.Stdout) if req.Body != nil { - req.Body = ioutil.NopCloser(&buf) + req.Body = io.NopCloser(&buf) } os.Stdout.Write([]byte("\n[/request]\n")) @@ -40,7 +39,7 @@ func (t *logTransport) RoundTrip(req *http.Request) (*http.Response, error) { res.Body = nil res.Write(os.Stdout) if body != nil { - res.Body = ioutil.NopCloser(&echoAsRead{body}) + res.Body = io.NopCloser(&echoAsRead{body}) } } diff --git a/examples/main.go b/examples/main.go index e60c16bafe2..0a2a2bd2073 100644 --- a/examples/main.go +++ b/examples/main.go @@ -11,7 +11,6 @@ import ( "flag" "fmt" "hash/fnv" - "io/ioutil" "log" "net/http" "net/http/httptest" @@ -198,7 +197,7 @@ func valueOrFileContents(value string, filename string) string { if value != "" { return value } - slurp, err := ioutil.ReadFile(filename) + slurp, err := os.ReadFile(filename) if err != nil { log.Fatalf("Error reading %q: %v", filename, err) } diff --git a/google-api-go-generator/clients_test.go b/google-api-go-generator/clients_test.go index 9a9467e42d1..f8b8105bf08 100644 --- a/google-api-go-generator/clients_test.go +++ b/google-api-go-generator/clients_test.go @@ -8,7 +8,7 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" + "io" "math" "net/http" "net/http/httptest" @@ -47,7 +47,7 @@ func (h *myHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { if h.location != "" { w.Header().Set("Location", h.location) } - h.body, h.err = ioutil.ReadAll(r.Body) + h.body, h.err = io.ReadAll(r.Body) fmt.Fprintf(w, "{}") } diff --git a/google-api-go-generator/gen.go b/google-api-go-generator/gen.go index 33e2ee9eb67..26704bae038 100644 --- a/google-api-go-generator/gen.go +++ b/google-api-go-generator/gen.go @@ -12,7 +12,6 @@ import ( "fmt" "go/format" "io" - "io/ioutil" "log" "net/http" "net/url" @@ -214,7 +213,7 @@ func getAPIs() []*API { log.Fatalf("-cache=true not compatible with -publiconly=false") } var err error - bytes, err = ioutil.ReadFile(apiListFile) + bytes, err = os.ReadFile(apiListFile) if err != nil { log.Fatal(err) } @@ -275,7 +274,7 @@ func getAPIsFromFile() []*API { } func apiFromFile(file string) (*API, error) { - jsonBytes, err := ioutil.ReadFile(file) + jsonBytes, err := os.ReadFile(file) if err != nil { return nil, fmt.Errorf("Error reading %s: %v", file, err) } @@ -298,7 +297,7 @@ func checkAndUpdateSpecFile(file string, contents []byte) error { if _, err := os.Stat(file); os.IsNotExist(err) { return writeFile(file, contents) } - existing, err := ioutil.ReadFile(file) + existing, err := os.ReadFile(file) if err != nil { return err } @@ -329,7 +328,7 @@ func isNewerRevision(old []byte, new []byte) error { func writeFile(file string, contents []byte) error { // Don't write it if the contents are identical. - existing, err := ioutil.ReadFile(file) + existing, err := os.ReadFile(file) if err == nil && (bytes.Equal(existing, contents) || basicallyEqual(existing, contents)) { return nil } @@ -337,7 +336,7 @@ func writeFile(file string, contents []byte) error { if err = os.MkdirAll(outdir, 0755); err != nil { return fmt.Errorf("failed to Mkdir %s: %v", outdir, err) } - return ioutil.WriteFile(file, contents, 0644) + return os.WriteFile(file, contents, 0644) } var ignoreLines = regexp.MustCompile(`(?m)^\s+"(?:etag|revision)": ".+\n`) @@ -368,7 +367,7 @@ func slurpURL(urlStr string) []byte { log.Printf("WARNING: URL %s served status code %d", urlStr, res.StatusCode) return nil } - bs, err := ioutil.ReadAll(res.Body) + bs, err := io.ReadAll(res.Body) if err != nil { log.Fatalf("Error reading body of URL %s: %v", urlStr, err) } @@ -523,7 +522,7 @@ func (a *API) jsonBytes() []byte { var slurp []byte var err error if *useCache { - slurp, err = ioutil.ReadFile(a.JSONFile()) + slurp, err = os.ReadFile(a.JSONFile()) if err != nil { log.Fatal(err) } diff --git a/google-api-go-generator/gen_test.go b/google-api-go-generator/gen_test.go index 63a59314bcc..5c598016a55 100644 --- a/google-api-go-generator/gen_test.go +++ b/google-api-go-generator/gen_test.go @@ -11,7 +11,7 @@ import ( "bytes" "flag" "fmt" - "io/ioutil" + "os" "path/filepath" "strings" "testing" @@ -63,17 +63,17 @@ func TestAPIs(t *testing.T) { goldenFile := filepath.Join("testdata", name+".want") if *updateGolden { clean := strings.Replace(string(clean), fmt.Sprintf("gdcl/%s", internal.Version), "gdcl/00000000", -1) - if err := ioutil.WriteFile(goldenFile, []byte(clean), 0644); err != nil { + if err := os.WriteFile(goldenFile, []byte(clean), 0644); err != nil { t.Fatal(err) } } - want, err := ioutil.ReadFile(goldenFile) + want, err := os.ReadFile(goldenFile) if err != nil { t.Fatal(err) } wantStr := strings.Replace(string(want), "gdcl/00000000", fmt.Sprintf("gdcl/%s", internal.Version), -1) if !bytes.Equal([]byte(wantStr), clean) { - tf, _ := ioutil.TempFile("", "api-"+name+"-got-json.") + tf, _ := os.CreateTemp("", "api-"+name+"-got-json.") if _, err := tf.Write(clean); err != nil { t.Fatal(err) } @@ -219,13 +219,13 @@ func TestSupportsPaging(t *testing.T) { func TestIsNewerRevision(t *testing.T) { olderBytesPath, newerBytesPath := filepath.Join("testdata", "rev20200415.json"), filepath.Join("testdata", "rev20200416.json") - olderBytes, err := ioutil.ReadFile(olderBytesPath) + olderBytes, err := os.ReadFile(olderBytesPath) if err != nil { - t.Fatalf("ioutil.ReadFile(%q) = %v; want nil", olderBytesPath, err) + t.Fatalf("os.ReadFile(%q) = %v; want nil", olderBytesPath, err) } - newerBytes, err := ioutil.ReadFile(newerBytesPath) + newerBytes, err := os.ReadFile(newerBytesPath) if err != nil { - t.Fatalf("ioutil.ReadFile(%q) = %v; want nil", newerBytesPath, err) + t.Fatalf("os.ReadFile(%q) = %v; want nil", newerBytesPath, err) } // newBytes > oldBytes diff --git a/google-api-go-generator/internal/disco/disco_test.go b/google-api-go-generator/internal/disco/disco_test.go index d4ae90e6a62..287b2cc520b 100644 --- a/google-api-go-generator/internal/disco/disco_test.go +++ b/google-api-go-generator/internal/disco/disco_test.go @@ -5,7 +5,7 @@ package disco import ( - "io/ioutil" + "os" "reflect" "strings" "testing" @@ -17,7 +17,7 @@ var stringSchema = &Schema{ } func TestDocument(t *testing.T) { - bytes, err := ioutil.ReadFile("testdata/test-api.json") + bytes, err := os.ReadFile("testdata/test-api.json") if err != nil { t.Fatal(err) } @@ -265,7 +265,7 @@ func TestSchemaErrors(t *testing.T) { } func TestErrorDoc(t *testing.T) { - bytes, err := ioutil.ReadFile("testdata/error.json") + bytes, err := os.ReadFile("testdata/error.json") if err != nil { t.Fatal(err) } diff --git a/googleapi/googleapi.go b/googleapi/googleapi.go index b328a7976ab..b5e38c66282 100644 --- a/googleapi/googleapi.go +++ b/googleapi/googleapi.go @@ -11,7 +11,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "net/url" "strings" @@ -144,7 +143,7 @@ func CheckResponse(res *http.Response) error { if res.StatusCode >= 200 && res.StatusCode <= 299 { return nil } - slurp, err := ioutil.ReadAll(res.Body) + slurp, err := io.ReadAll(res.Body) if err == nil { jerr := new(errorReply) err = json.Unmarshal(slurp, jerr) @@ -184,7 +183,7 @@ func CheckMediaResponse(res *http.Response) error { if res.StatusCode >= 200 && res.StatusCode <= 299 { return nil } - slurp, _ := ioutil.ReadAll(io.LimitReader(res.Body, 1<<20)) + slurp, _ := io.ReadAll(io.LimitReader(res.Body, 1<<20)) return &Error{ Code: res.StatusCode, Body: string(slurp), diff --git a/googleapi/googleapi_test.go b/googleapi/googleapi_test.go index 510a5842630..db06aa273ee 100644 --- a/googleapi/googleapi_test.go +++ b/googleapi/googleapi_test.go @@ -6,7 +6,7 @@ package googleapi import ( "encoding/json" - "io/ioutil" + "io" "net/http" "net/url" "reflect" @@ -318,7 +318,7 @@ func TestCheckResponse(t *testing.T) { for _, test := range checkResponseTests { res := test.in if test.bodyText != "" { - res.Body = ioutil.NopCloser(strings.NewReader(test.bodyText)) + res.Body = io.NopCloser(strings.NewReader(test.bodyText)) } g := CheckResponse(res) if !reflect.DeepEqual(g, test.want) { diff --git a/header_test.go b/header_test.go index 5881762081c..a493d25027a 100644 --- a/header_test.go +++ b/header_test.go @@ -6,7 +6,6 @@ package api import ( "bytes" - "io/ioutil" "os" "path/filepath" "regexp" @@ -43,7 +42,7 @@ func TestLicense(t *testing.T) { return nil } - src, err := ioutil.ReadFile(path) + src, err := os.ReadFile(path) if err != nil { return nil } diff --git a/idtoken/validate_test.go b/idtoken/validate_test.go index 631c82e88dc..46528db2747 100644 --- a/idtoken/validate_test.go +++ b/idtoken/validate_test.go @@ -14,7 +14,7 @@ import ( "crypto/rsa" "encoding/base64" "encoding/json" - "io/ioutil" + "io" "math/big" "net/http" "testing" @@ -97,7 +97,7 @@ func TestValidateRS256(t *testing.T) { } return &http.Response{ StatusCode: 200, - Body: ioutil.NopCloser(bytes.NewReader(b)), + Body: io.NopCloser(bytes.NewReader(b)), Header: make(http.Header), } }), @@ -207,7 +207,7 @@ func TestValidateES256(t *testing.T) { } return &http.Response{ StatusCode: 200, - Body: ioutil.NopCloser(bytes.NewReader(b)), + Body: io.NopCloser(bytes.NewReader(b)), Header: make(http.Header), } }), diff --git a/impersonate/idtoken.go b/impersonate/idtoken.go index a2defff1518..9000b8e0f61 100644 --- a/impersonate/idtoken.go +++ b/impersonate/idtoken.go @@ -10,7 +10,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "time" @@ -109,7 +108,7 @@ func (i impersonatedIDTokenSource) Token() (*oauth2.Token, error) { return nil, fmt.Errorf("impersonate: unable to generate ID token: %v", err) } defer resp.Body.Close() - body, err := ioutil.ReadAll(io.LimitReader(resp.Body, 1<<20)) + body, err := io.ReadAll(io.LimitReader(resp.Body, 1<<20)) if err != nil { return nil, fmt.Errorf("impersonate: unable to read body: %v", err) } diff --git a/impersonate/idtoken_test.go b/impersonate/idtoken_test.go index 4a961822bdf..45d4305a90b 100644 --- a/impersonate/idtoken_test.go +++ b/impersonate/idtoken_test.go @@ -8,7 +8,7 @@ import ( "bytes" "context" "encoding/json" - "io/ioutil" + "io" "net/http" "testing" @@ -56,7 +56,7 @@ func TestIDTokenSource(t *testing.T) { } return &http.Response{ StatusCode: 200, - Body: ioutil.NopCloser(bytes.NewReader(b)), + Body: io.NopCloser(bytes.NewReader(b)), Header: make(http.Header), } }), diff --git a/impersonate/impersonate.go b/impersonate/impersonate.go index 52c32589b72..86d5eb82d58 100644 --- a/impersonate/impersonate.go +++ b/impersonate/impersonate.go @@ -10,7 +10,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "time" @@ -161,7 +160,7 @@ func (i impersonatedTokenSource) Token() (*oauth2.Token, error) { return nil, fmt.Errorf("impersonate: unable to generate access token: %v", err) } defer resp.Body.Close() - body, err := ioutil.ReadAll(io.LimitReader(resp.Body, 1<<20)) + body, err := io.ReadAll(io.LimitReader(resp.Body, 1<<20)) if err != nil { return nil, fmt.Errorf("impersonate: unable to read body: %v", err) } diff --git a/impersonate/impersonate_test.go b/impersonate/impersonate_test.go index c26c7fafc1a..8e6a09ac9a2 100644 --- a/impersonate/impersonate_test.go +++ b/impersonate/impersonate_test.go @@ -8,7 +8,7 @@ import ( "bytes" "context" "encoding/json" - "io/ioutil" + "io" "net/http" "strings" "testing" @@ -67,7 +67,7 @@ func TestTokenSource_serviceAccount(t *testing.T) { } return &http.Response{ StatusCode: 200, - Body: ioutil.NopCloser(bytes.NewReader(b)), + Body: io.NopCloser(bytes.NewReader(b)), Header: http.Header{}, } } diff --git a/impersonate/user.go b/impersonate/user.go index 059deab7117..c234abb8998 100644 --- a/impersonate/user.go +++ b/impersonate/user.go @@ -10,7 +10,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "net/url" "strings" @@ -123,7 +122,7 @@ func (u userTokenSource) signJWT() (string, error) { if err != nil { return "", fmt.Errorf("impersonate: unable to sign JWT: %v", err) } - body, err := ioutil.ReadAll(io.LimitReader(rawResp.Body, 1<<20)) + body, err := io.ReadAll(io.LimitReader(rawResp.Body, 1<<20)) if err != nil { return "", fmt.Errorf("impersonate: unable to read body: %v", err) } @@ -148,7 +147,7 @@ func (u userTokenSource) exchangeToken(signedJWT string) (*oauth2.Token, error) if err != nil { return nil, fmt.Errorf("impersonate: unable to exchange token: %v", err) } - body, err := ioutil.ReadAll(io.LimitReader(rawResp.Body, 1<<20)) + body, err := io.ReadAll(io.LimitReader(rawResp.Body, 1<<20)) if err != nil { return nil, fmt.Errorf("impersonate: unable to read body: %v", err) } diff --git a/impersonate/user_test.go b/impersonate/user_test.go index 0358eecc883..54ec3068d3a 100644 --- a/impersonate/user_test.go +++ b/impersonate/user_test.go @@ -8,7 +8,7 @@ import ( "bytes" "context" "encoding/json" - "io/ioutil" + "io" "net/http" "strings" "testing" @@ -69,7 +69,7 @@ func TestTokenSource_user(t *testing.T) { } return &http.Response{ StatusCode: 200, - Body: ioutil.NopCloser(bytes.NewReader(b)), + Body: io.NopCloser(bytes.NewReader(b)), Header: make(http.Header), } } @@ -85,7 +85,7 @@ func TestTokenSource_user(t *testing.T) { } return &http.Response{ StatusCode: 200, - Body: ioutil.NopCloser(bytes.NewReader(b)), + Body: io.NopCloser(bytes.NewReader(b)), Header: make(http.Header), } } diff --git a/integration-tests/byoid/integration_test.go b/integration-tests/byoid/integration_test.go index 612cf8eae4c..e0051c470d9 100644 --- a/integration-tests/byoid/integration_test.go +++ b/integration-tests/byoid/integration_test.go @@ -33,7 +33,7 @@ import ( "encoding/xml" "flag" "fmt" - "io/ioutil" + "io" "log" "net/http" "net/http/httptest" @@ -148,7 +148,7 @@ func writeConfig(t *testing.T, c config, f func(name string)) { t.Helper() // Set up config file. - configFile, err := ioutil.TempFile("", "config.json") + configFile, err := os.CreateTemp("", "config.json") if err != nil { t.Fatalf("Error creating config file: %v", err) } @@ -223,7 +223,7 @@ func TestFileBasedCredentials(t *testing.T) { t.Skip("skipping integration test") } // Set up Token as a file - tokenFile, err := ioutil.TempFile("", "token.txt") + tokenFile, err := os.CreateTemp("", "token.txt") if err != nil { t.Fatalf("Error creating token file:") } @@ -313,7 +313,7 @@ func TestAWSBasedCredentials(t *testing.T) { if err != nil { t.Fatalf("Failed to post data to AWS: %v", err) } - bodyBytes, err := ioutil.ReadAll(resp.Body) + bodyBytes, err := io.ReadAll(resp.Body) if err != nil { t.Fatalf("Failed to parse response body from AWS: %v", err) } @@ -369,7 +369,7 @@ func TestExecutableBasedCredentials(t *testing.T) { } // Set up Script as a executable file - scriptFile, err := ioutil.TempFile("", "script.sh") + scriptFile, err := os.CreateTemp("", "script.sh") if err != nil { t.Fatalf("Error creating token file:") } @@ -402,7 +402,7 @@ func TestConfigurableTokenLifetime(t *testing.T) { } // Set up Token as a file - tokenFile, err := ioutil.TempFile("", "token.txt") + tokenFile, err := os.CreateTemp("", "token.txt") if err != nil { t.Fatalf("Error creating token file:") } @@ -427,7 +427,7 @@ func TestConfigurableTokenLifetime(t *testing.T) { File: tokenFile.Name(), }, }, func(filename string) { - b, err := ioutil.ReadFile(filename) + b, err := os.ReadFile(filename) if err != nil { t.Fatalf("Coudn't read temp config file") } diff --git a/integration-tests/downscope/downscope_test.go b/integration-tests/downscope/downscope_test.go index 25553c9c2d7..12ed93d2735 100644 --- a/integration-tests/downscope/downscope_test.go +++ b/integration-tests/downscope/downscope_test.go @@ -8,7 +8,7 @@ import ( "context" "flag" "fmt" - "io/ioutil" + "io" "log" "os" "testing" @@ -137,9 +137,9 @@ func downscopeQuery(t *testing.T, tt downscopeTest) error { return fmt.Errorf("failed to retrieve object from GCP project with error: %v", err) } defer resp.Body.Close() - _, err = ioutil.ReadAll(resp.Body) + _, err = io.ReadAll(resp.Body) if err != nil { - return fmt.Errorf("ioutil.ReadAll: %v", err) + return fmt.Errorf("io.ReadAll: %v", err) } return nil } diff --git a/internal/cert/secureconnect_cert.go b/internal/cert/secureconnect_cert.go index 5913cab8017..afd79ffe2be 100644 --- a/internal/cert/secureconnect_cert.go +++ b/internal/cert/secureconnect_cert.go @@ -18,7 +18,6 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" "os" "os/exec" "os/user" @@ -59,7 +58,7 @@ func NewSecureConnectSource(configFilePath string) (Source, error) { configFilePath = filepath.Join(user.HomeDir, metadataPath, metadataFile) } - file, err := ioutil.ReadFile(configFilePath) + file, err := os.ReadFile(configFilePath) if err != nil { if errors.Is(err, os.ErrNotExist) { // Config file missing means Secure Connect is not supported. diff --git a/internal/creds.go b/internal/creds.go index fd89a2785fd..92b3acf6edf 100644 --- a/internal/creds.go +++ b/internal/creds.go @@ -10,7 +10,6 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" "net" "net/http" "os" @@ -48,7 +47,7 @@ func baseCreds(ctx context.Context, ds *DialSettings) (*google.Credentials, erro return credentialsFromJSON(ctx, ds.CredentialsJSON, ds) } if ds.CredentialsFile != "" { - data, err := ioutil.ReadFile(ds.CredentialsFile) + data, err := os.ReadFile(ds.CredentialsFile) if err != nil { return nil, fmt.Errorf("cannot read credentials file: %v", err) } diff --git a/internal/ecp/test_signer.go b/internal/ecp/test_signer.go index 38425cf677b..4fb41ea98e4 100644 --- a/internal/ecp/test_signer.go +++ b/internal/ecp/test_signer.go @@ -11,7 +11,6 @@ import ( "crypto/tls" "crypto/x509" "io" - "io/ioutil" "log" "net/rpc" "os" @@ -73,7 +72,7 @@ func (k *EnterpriseCertSigner) Sign(args SignArgs, resp *[]byte) (err error) { func main() { enterpriseCertSigner := new(EnterpriseCertSigner) - data, err := ioutil.ReadFile(os.Args[1]) + data, err := os.ReadFile(os.Args[1]) if err != nil { log.Fatalf("Error reading certificate: %v", err) } diff --git a/internal/gensupport/buffer_test.go b/internal/gensupport/buffer_test.go index df5eedb8ff0..8a99744bfbe 100644 --- a/internal/gensupport/buffer_test.go +++ b/internal/gensupport/buffer_test.go @@ -7,7 +7,6 @@ package gensupport import ( "bytes" "io" - "io/ioutil" "reflect" "testing" "testing/iotest" @@ -19,7 +18,7 @@ import ( func getChunkAsString(t *testing.T, mb *MediaBuffer) (string, error) { chunk, _, size, err := mb.Chunk() - buf, e := ioutil.ReadAll(chunk) + buf, e := io.ReadAll(chunk) if e != nil { t.Fatalf("Failed reading chunk: %v", e) } @@ -250,7 +249,7 @@ func TestAdapter(t *testing.T) { if typer, ok := to.(googleapi.ContentTyper); ok && typer.ContentType() != "ctype" { t.Errorf("content type: got: %s; want: ctype", typer.ContentType()) } - buf, err := ioutil.ReadAll(to) + buf, err := io.ReadAll(to) if err != nil { t.Errorf("error reading data: %v", err) return diff --git a/internal/gensupport/media.go b/internal/gensupport/media.go index 8356e7f27b0..c048a57084b 100644 --- a/internal/gensupport/media.go +++ b/internal/gensupport/media.go @@ -8,7 +8,6 @@ import ( "bytes" "fmt" "io" - "io/ioutil" "mime" "mime/multipart" "net/http" @@ -222,8 +221,8 @@ func (mi *MediaInfo) UploadRequest(reqHeaders http.Header, body io.Reader) (newB toCleanup = append(toCleanup, combined) if fb != nil && fm != nil { getBody = func() (io.ReadCloser, error) { - rb := ioutil.NopCloser(fb()) - rm := ioutil.NopCloser(fm()) + rb := io.NopCloser(fb()) + rm := io.NopCloser(fm()) var mimeBoundary string if _, params, err := mime.ParseMediaType(ctype); err == nil { mimeBoundary = params["boundary"] @@ -243,7 +242,7 @@ func (mi *MediaInfo) UploadRequest(reqHeaders http.Header, body io.Reader) (newB fb := readerFunc(body) if fb != nil { getBody = func() (io.ReadCloser, error) { - rb := ioutil.NopCloser(fb()) + rb := io.NopCloser(fb()) toCleanup = append(toCleanup, rb) return rb, nil } diff --git a/internal/gensupport/media_test.go b/internal/gensupport/media_test.go index 0ba367b4469..65fd62b3dcc 100644 --- a/internal/gensupport/media_test.go +++ b/internal/gensupport/media_test.go @@ -8,7 +8,6 @@ import ( "bytes" cryptorand "crypto/rand" "io" - "io/ioutil" mathrand "math/rand" "net/http" "strings" @@ -197,7 +196,7 @@ func TestUploadRequestGetBody(t *testing.T) { if getBody == nil { continue } - want, err := ioutil.ReadAll(r) + want, err := io.ReadAll(r) if err != nil { t.Fatal(err) } @@ -206,7 +205,7 @@ func TestUploadRequestGetBody(t *testing.T) { if err != nil { t.Fatal(err) } - got, err := ioutil.ReadAll(rc) + got, err := io.ReadAll(rc) if err != nil { t.Fatal(err) } diff --git a/internal/gensupport/resumable_test.go b/internal/gensupport/resumable_test.go index 3d6bc068bab..0000d403e0c 100644 --- a/internal/gensupport/resumable_test.go +++ b/internal/gensupport/resumable_test.go @@ -8,7 +8,6 @@ import ( "context" "fmt" "io" - "io/ioutil" "net/http" "reflect" "strings" @@ -75,7 +74,7 @@ func (t *interruptibleTransport) RoundTrip(req *http.Request) (*http.Response, e } if ev.responseStatus != http.StatusServiceUnavailable { - buf, err := ioutil.ReadAll(req.Body) + buf, err := io.ReadAll(req.Body) if err != nil { return nil, fmt.Errorf("error reading from request data: %v", err) } diff --git a/internal/impersonate/impersonate.go b/internal/impersonate/impersonate.go index b465bbcd12e..4b2c775f210 100644 --- a/internal/impersonate/impersonate.go +++ b/internal/impersonate/impersonate.go @@ -11,7 +11,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "net/http" "time" @@ -105,7 +104,7 @@ func (i impersonatedTokenSource) Token() (*oauth2.Token, error) { return nil, fmt.Errorf("impersonate: unable to generate access token: %v", err) } defer resp.Body.Close() - body, err := ioutil.ReadAll(io.LimitReader(resp.Body, 1<<20)) + body, err := io.ReadAll(io.LimitReader(resp.Body, 1<<20)) if err != nil { return nil, fmt.Errorf("impersonate: unable to read body: %v", err) }