Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite2bb5be

Browse files
committed
Migrate from deprecatedio/ioutil
1 parent14fb98e commite2bb5be

File tree

7 files changed

+18
-22
lines changed

7 files changed

+18
-22
lines changed

‎autobahn_test.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"context"
77
"encoding/json"
88
"fmt"
9-
"io/ioutil"
9+
"io"
1010
"net"
1111
"os"
1212
"os/exec"
@@ -146,7 +146,7 @@ func wstestCaseCount(ctx context.Context, url string) (cases int, err error) {
146146
iferr!=nil {
147147
return0,err
148148
}
149-
b,err:=ioutil.ReadAll(r)
149+
b,err:=io.ReadAll(r)
150150
iferr!=nil {
151151
return0,err
152152
}
@@ -161,7 +161,7 @@ func wstestCaseCount(ctx context.Context, url string) (cases int, err error) {
161161
}
162162

163163
funccheckWSTestIndex(t*testing.T,pathstring) {
164-
wstestOut,err:=ioutil.ReadFile(path)
164+
wstestOut,err:=os.ReadFile(path)
165165
assert.Success(t,err)
166166

167167
varindexJSONmap[string]map[string]struct {
@@ -206,7 +206,7 @@ func unusedListenAddr() (_ string, err error) {
206206
}
207207

208208
functempJSONFile(vinterface{}) (string,error) {
209-
f,err:=ioutil.TempFile("","temp.json")
209+
f,err:=os.CreateTemp("","temp.json")
210210
iferr!=nil {
211211
return"",fmt.Errorf("temp file: %w",err)
212212
}

‎conn_test.go‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"context"
88
"fmt"
99
"io"
10-
"io/ioutil"
1110
"net/http"
1211
"net/http/httptest"
1312
"os"
@@ -174,7 +173,7 @@ func TestConn(t *testing.T) {
174173
returnn2.Close()
175174
})
176175

177-
b,err:=ioutil.ReadAll(n1)
176+
b,err:=io.ReadAll(n1)
178177
assert.Success(t,err)
179178

180179
_,err=n1.Read(nil)
@@ -205,7 +204,7 @@ func TestConn(t *testing.T) {
205204
returnnil
206205
})
207206

208-
_,err:=ioutil.ReadAll(n1)
207+
_,err:=io.ReadAll(n1)
209208
assert.Contains(t,err,`unexpected frame type read (expected MessageBinary): MessageText`)
210209

211210
select {

‎dial.go‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"encoding/base64"
1111
"fmt"
1212
"io"
13-
"io/ioutil"
1413
"net/http"
1514
"net/url"
1615
"strings"
@@ -114,9 +113,9 @@ func dial(ctx context.Context, urls string, opts *DialOptions, rand io.Reader) (
114113
})
115114
defertimer.Stop()
116115

117-
b,_:=ioutil.ReadAll(r)
116+
b,_:=io.ReadAll(r)
118117
respBody.Close()
119-
resp.Body=ioutil.NopCloser(bytes.NewReader(b))
118+
resp.Body=io.NopCloser(bytes.NewReader(b))
120119
}
121120
}()
122121

‎dial_test.go‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"context"
77
"crypto/rand"
88
"io"
9-
"io/ioutil"
109
"net/http"
1110
"net/http/httptest"
1211
"strings"
@@ -75,7 +74,7 @@ func TestBadDials(t *testing.T) {
7574
_,_,err:=Dial(ctx,"ws://example.com",&DialOptions{
7675
HTTPClient:mockHTTPClient(func(*http.Request) (*http.Response,error) {
7776
return&http.Response{
78-
Body:ioutil.NopCloser(strings.NewReader("hi")),
77+
Body:io.NopCloser(strings.NewReader("hi")),
7978
},nil
8079
}),
8180
})
@@ -97,7 +96,7 @@ func TestBadDials(t *testing.T) {
9796
return&http.Response{
9897
StatusCode:http.StatusSwitchingProtocols,
9998
Header:h,
100-
Body:ioutil.NopCloser(strings.NewReader("hi")),
99+
Body:io.NopCloser(strings.NewReader("hi")),
101100
},nil
102101
}
103102

‎doc.go‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
//
1717
// More documentation at https://nhooyr.io/websocket.
1818
//
19-
// Wasm
19+
//#Wasm
2020
//
2121
// The client side supports compiling to Wasm.
2222
// It wraps the WebSocket browser API.
@@ -25,8 +25,8 @@
2525
//
2626
// Some important caveats to be aware of:
2727
//
28-
// - Accept always errors out
29-
// - Conn.Ping is no-op
30-
// - HTTPClient, HTTPHeader and CompressionMode in DialOptions are no-op
31-
// - *http.Response from Dial is &http.Response{} with a 101 status code on success
28+
//- Accept always errors out
29+
//- Conn.Ping is no-op
30+
//- HTTPClient, HTTPHeader and CompressionMode in DialOptions are no-op
31+
//- *http.Response from Dial is &http.Response{} with a 101 status code on success
3232
package websocket// import "nhooyr.io/websocket"

‎examples/chat/chat.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package main
33
import (
44
"context"
55
"errors"
6-
"io/ioutil"
6+
"io"
77
"log"
88
"net/http"
99
"sync"
@@ -98,7 +98,7 @@ func (cs *chatServer) publishHandler(w http.ResponseWriter, r *http.Request) {
9898
return
9999
}
100100
body:=http.MaxBytesReader(w,r.Body,8192)
101-
msg,err:=ioutil.ReadAll(body)
101+
msg,err:=io.ReadAll(body)
102102
iferr!=nil {
103103
http.Error(w,http.StatusText(http.StatusRequestEntityTooLarge),http.StatusRequestEntityTooLarge)
104104
return

‎read.go‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"errors"
99
"fmt"
1010
"io"
11-
"io/ioutil"
1211
"strings"
1312
"time"
1413

@@ -38,7 +37,7 @@ func (c *Conn) Read(ctx context.Context) (MessageType, []byte, error) {
3837
return0,nil,err
3938
}
4039

41-
b,err:=ioutil.ReadAll(r)
40+
b,err:=io.ReadAll(r)
4241
returntyp,b,err
4342
}
4443

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp