all: Remove usage of deprecated io/ioutil (#7971)

As of Go 1.16 io/ioutil is deprecated. This replaces usage with the
corresponding functions in package os and package io.
This commit is contained in:
Jakob Borg
2021-11-22 08:59:47 +01:00
committed by GitHub
parent bf89bffb0b
commit 4b750b6dc3
71 changed files with 190 additions and 235 deletions
+2 -3
View File
@@ -10,7 +10,6 @@ import (
"bytes"
"compress/gzip"
"io"
"io/ioutil"
"net/http"
"net/http/httptest"
"strconv"
@@ -31,7 +30,7 @@ func compress(s string) string {
func decompress(p []byte) (out []byte) {
r, err := gzip.NewReader(bytes.NewBuffer(p))
if err == nil {
out, err = ioutil.ReadAll(r)
out, err = io.ReadAll(r)
}
if err != nil {
panic(err)
@@ -81,7 +80,7 @@ func testServe(t *testing.T, gzip bool) {
t.Errorf("unexpected ETag %q", etag)
}
body, _ := ioutil.ReadAll(res.Body)
body, _ := io.ReadAll(res.Body)
// Content-Length is the number of bytes in the encoded (compressed) body
// (https://stackoverflow.com/a/3819303).