chore: remove refs to deprecated io/ioutil

This commit is contained in:
guoguangwu
2023-06-21 12:12:27 +08:00
parent 339e243472
commit 6dc23ca804
15 changed files with 36 additions and 43 deletions
+2 -2
View File
@@ -16,7 +16,7 @@ limitations under the License.
package metrics
import (
"io/ioutil"
"os"
"testing"
)
@@ -121,7 +121,7 @@ func TestPrometheusMetricsParsingAndMatching(t *testing.T) {
for _, test := range testCases {
t.Run(test.name, func(t *testing.T) {
b, err := ioutil.ReadFile(test.metricsTextPath)
b, err := os.ReadFile(test.metricsTextPath)
if err != nil {
t.Errorf("Unexpected error reading file %s: %v", test.metricsTextPath, err)
}
+3 -3
View File
@@ -28,7 +28,7 @@ import (
"crypto/sha512"
"encoding/hex"
"flag"
"io/ioutil"
"io"
"log"
"net/http"
"strings"
@@ -92,7 +92,7 @@ func main() {
if res.ContentLength != objectLength {
log.Fatalf("Length reported (%d) is not equal to expected length (%d)", res.ContentLength, objectLength)
}
blobData, err := ioutil.ReadAll(res.Body)
blobData, err := io.ReadAll(res.Body)
res.Body.Close()
if err != nil {
log.Fatal("Failed to read full content", err)
@@ -110,7 +110,7 @@ func main() {
if err != nil {
log.Fatalf("Failure (%s) while reading %s", err, objectHashUrl)
}
content, err := ioutil.ReadAll(res.Body)
content, err := io.ReadAll(res.Body)
res.Body.Close()
if err != nil {
log.Fatal("Failed to read full content of hash file", err)