diff --git a/autobahn_test.go b/autobahn_test.go index 23723b51b058e862c9cbcfd7acc0c9eacacdb8ba..8100c37fbaf8a70e0ea4a01862e4442fdd0df114 100644 --- a/autobahn_test.go +++ b/autobahn_test.go @@ -7,7 +7,7 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" + "io" "net" "os" "os/exec" @@ -202,7 +202,7 @@ func wstestCaseCount(ctx context.Context, url string) (cases int, err error) { if err != nil { return 0, err } - b, err := ioutil.ReadAll(r) + b, err := io.ReadAll(r) if err != nil { return 0, err } @@ -217,7 +217,7 @@ func wstestCaseCount(ctx context.Context, url string) (cases int, err error) { } func checkWSTestIndex(t *testing.T, path string) { - wstestOut, err := ioutil.ReadFile(path) + wstestOut, err := os.ReadFile(path) assert.Success(t, err) var indexJSON map[string]map[string]struct { @@ -262,7 +262,7 @@ func unusedListenAddr() (_ string, err error) { } func tempJSONFile(v interface{}) (string, error) { - f, err := ioutil.TempFile("", "temp.json") + f, err := os.CreateTemp("", "temp.json") if err != nil { return "", fmt.Errorf("temp file: %w", err) } diff --git a/conn_test.go b/conn_test.go index 19961d18d3c82519ecb06929f05daa46ad0b19b6..f474ae0c13f671e98585b3f18fa8f4b34a0db089 100644 --- a/conn_test.go +++ b/conn_test.go @@ -8,7 +8,6 @@ import ( "context" "fmt" "io" - "io/ioutil" "net/http" "net/http/httptest" "os" @@ -170,7 +169,7 @@ func TestConn(t *testing.T) { return n2.Close() }) - b, err := ioutil.ReadAll(n1) + b, err := io.ReadAll(n1) assert.Success(t, err) _, err = n1.Read(nil) @@ -198,7 +197,7 @@ func TestConn(t *testing.T) { return err }) - _, err := ioutil.ReadAll(n1) + _, err := io.ReadAll(n1) assert.Contains(t, err, `unexpected frame type read (expected MessageBinary): MessageText`) select { diff --git a/dial.go b/dial.go index 7e77d6e309a04e5c4f48548daeddba94c405100f..feffae8ba7500443ce8d635f7e4a3caa0674f18e 100644 --- a/dial.go +++ b/dial.go @@ -11,7 +11,6 @@ import ( "encoding/base64" "fmt" "io" - "io/ioutil" "net/http" "net/url" "strings" @@ -122,9 +121,9 @@ func dial(ctx context.Context, urls string, opts *DialOptions, rand io.Reader) ( }) defer timer.Stop() - b, _ := ioutil.ReadAll(r) + b, _ := io.ReadAll(r) respBody.Close() - resp.Body = ioutil.NopCloser(bytes.NewReader(b)) + resp.Body = io.NopCloser(bytes.NewReader(b)) } }() diff --git a/dial_test.go b/dial_test.go index e5f8ab3d5f8a8be50793e03c0f2a30a657717885..71425e11f6f89cd6f9860654d127f9acd9bb5e38 100644 --- a/dial_test.go +++ b/dial_test.go @@ -7,7 +7,6 @@ import ( "context" "crypto/rand" "io" - "io/ioutil" "net/http" "net/http/httptest" "strings" @@ -76,7 +75,7 @@ func TestBadDials(t *testing.T) { _, _, err := Dial(ctx, "ws://example.com", &DialOptions{ HTTPClient: mockHTTPClient(func(*http.Request) (*http.Response, error) { return &http.Response{ - Body: ioutil.NopCloser(strings.NewReader("hi")), + Body: io.NopCloser(strings.NewReader("hi")), }, nil }), }) @@ -98,7 +97,7 @@ func TestBadDials(t *testing.T) { return &http.Response{ StatusCode: http.StatusSwitchingProtocols, Header: h, - Body: ioutil.NopCloser(strings.NewReader("hi")), + Body: io.NopCloser(strings.NewReader("hi")), }, nil } diff --git a/examples/chat/chat.go b/examples/chat/chat.go index 532e50f544fbc39f2ca0a870b0c9cc7ef8ae8e44..9d393d873c3a343557ead1e62872c6f3e0e8098b 100644 --- a/examples/chat/chat.go +++ b/examples/chat/chat.go @@ -3,7 +3,7 @@ package main import ( "context" "errors" - "io/ioutil" + "io" "log" "net/http" "sync" @@ -98,7 +98,7 @@ func (cs *chatServer) publishHandler(w http.ResponseWriter, r *http.Request) { return } body := http.MaxBytesReader(w, r.Body, 8192) - msg, err := ioutil.ReadAll(body) + msg, err := io.ReadAll(body) if err != nil { http.Error(w, http.StatusText(http.StatusRequestEntityTooLarge), http.StatusRequestEntityTooLarge) return diff --git a/read.go b/read.go index 87e934605d6a7b6a8cfe61e76df9cf8d8fd72d1b..7bc6f20dbdec8bd8c0766e09cbb253657b66eaee 100644 --- a/read.go +++ b/read.go @@ -9,7 +9,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "strings" "time" @@ -44,7 +43,7 @@ func (c *Conn) Read(ctx context.Context) (MessageType, []byte, error) { return 0, nil, err } - b, err := ioutil.ReadAll(r) + b, err := io.ReadAll(r) return typ, b, err }