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:
@@ -18,7 +18,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"path"
|
||||
"strings"
|
||||
@@ -111,7 +111,7 @@ func (h *pipelineHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
// Limit the data size that could be read from the request body, which ensures that read from
|
||||
// connection will not time out accidentally due to possible blocking in underlying implementation.
|
||||
limitedr := pioutil.NewLimitedBufferReader(r.Body, connReadLimitByte)
|
||||
b, err := ioutil.ReadAll(limitedr)
|
||||
b, err := io.ReadAll(limitedr)
|
||||
if err != nil {
|
||||
h.lg.Warn(
|
||||
"failed to read Raft message",
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"runtime"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -154,7 +154,7 @@ func (p *pipeline) post(data []byte) (err error) {
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
b, err := ioutil.ReadAll(resp.Body)
|
||||
b, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
p.picker.unreachable(u)
|
||||
return err
|
||||
|
||||
@@ -18,7 +18,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"sync"
|
||||
"testing"
|
||||
@@ -158,7 +157,7 @@ func TestPipelinePost(t *testing.T) {
|
||||
if g := req.Header.Get("X-Etcd-Cluster-ID"); g != "1" {
|
||||
t.Errorf("cluster id = %s, want %s", g, "1")
|
||||
}
|
||||
b, err := ioutil.ReadAll(req.Body)
|
||||
b, err := io.ReadAll(req.Body)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected ReadAll error: %v", err)
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
@@ -169,7 +168,7 @@ func (s *snapshotSender) post(req *http.Request) (err error) {
|
||||
// prevents from reading the body forever when the other side dies right after
|
||||
// successfully receives the request body.
|
||||
time.AfterFunc(snapResponseReadTimeout, func() { httputil.GracefulClose(resp) })
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
result <- responseAndError{resp, body, err}
|
||||
}()
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ package rafthttp
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
@@ -94,8 +93,8 @@ func TestSnapshotSend(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func testSnapshotSend(t *testing.T, sm *snap.Message) (bool, []os.FileInfo) {
|
||||
d, err := ioutil.TempDir(os.TempDir(), "snapdir")
|
||||
func testSnapshotSend(t *testing.T, sm *snap.Message) (bool, []os.DirEntry) {
|
||||
d, err := os.MkdirTemp(os.TempDir(), "snapdir")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -124,7 +123,7 @@ func testSnapshotSend(t *testing.T, sm *snap.Message) (bool, []os.FileInfo) {
|
||||
// wait for handler to finish accepting snapshot
|
||||
<-ch
|
||||
|
||||
files, rerr := ioutil.ReadDir(d)
|
||||
files, rerr := os.ReadDir(d)
|
||||
if rerr != nil {
|
||||
t.Fatal(rerr)
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"path"
|
||||
"strings"
|
||||
@@ -629,7 +628,7 @@ func (cr *streamReader) dial(t streamType) (io.ReadCloser, error) {
|
||||
return nil, fmt.Errorf("peer %s failed to find local node %s", cr.peerID, cr.tr.ID)
|
||||
|
||||
case http.StatusPreconditionFailed:
|
||||
b, err := ioutil.ReadAll(resp.Body)
|
||||
b, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
cr.picker.unreachable(u)
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user