mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
*: move from io/ioutil to io and os packages
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:
@@ -5,7 +5,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
@@ -127,7 +126,7 @@ func TestHealthHandler(t *testing.T) {
|
||||
|
||||
func parseHealthOutput(body io.Reader) (Health, error) {
|
||||
obj := Health{}
|
||||
d, derr := ioutil.ReadAll(body)
|
||||
d, derr := io.ReadAll(body)
|
||||
if derr != nil {
|
||||
return obj, derr
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"path"
|
||||
@@ -98,9 +98,9 @@ func TestNewPeerHandlerOnRaftPrefix(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected http.Get error: %v", err)
|
||||
}
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected ioutil.ReadAll error: %v", err)
|
||||
t.Fatalf("unexpected io.ReadAll error: %v", err)
|
||||
}
|
||||
if w := "test data"; string(body) != w {
|
||||
t.Errorf("#%d: body = %s, want %s", i, body, w)
|
||||
@@ -267,10 +267,10 @@ func TestNewPeerHandlerOnMembersPromotePrefix(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("failed to get http response: %v", err)
|
||||
}
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
resp.Body.Close()
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected ioutil.ReadAll error: %v", err)
|
||||
t.Fatalf("unexpected io.ReadAll error: %v", err)
|
||||
}
|
||||
if resp.StatusCode != tt.wcode {
|
||||
t.Fatalf("#%d: code = %d, want %d", i, resp.StatusCode, tt.wcode)
|
||||
|
||||
Reference in New Issue
Block a user