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

Commit91013c1

Browse files
authored
chore: apply various modernisations (#531)
* Use any instead of interface{} given Go > 1.18* Minor tidies thanks to gofumpt* Run "go fix ./..." on the codebase* Apply a few modernisations suggested by gopls check* Remove unused parameter suggested by gopls check
1 parentefb626b commit91013c1

31 files changed

+50
-68
lines changed

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ http.HandlerFunc(func (w http.ResponseWriter, r *http.Request) {
6868
ctx,cancel:= context.WithTimeout(context.Background(), time.Second*10)
6969
defercancel()
7070

71-
varvinterface{}
71+
varvany
7272
err = wsjson.Read(ctx, c, &v)
7373
if err !=nil {
7474
// ...

‎accept.go‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build !js
2-
// +build !js
32

43
package websocket
54

‎accept_test.go‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build !js
2-
// +build !js
32

43
package websocket
54

‎autobahn_test.go‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build !js
2-
// +build !js
32

43
package websocket_test
54

@@ -130,7 +129,7 @@ func wstestServer(tb testing.TB, ctx context.Context) (url string, closeFn func(
130129
url="ws://"+serverAddr
131130
constoutDir="ci/out/autobahn-report"
132131

133-
specFile,err:=tempJSONFile(map[string]interface{}{
132+
specFile,err:=tempJSONFile(map[string]any{
134133
"url":url,
135134
"outdir":outDir,
136135
"cases":autobahnCases,
@@ -280,7 +279,7 @@ func unusedListenAddr() (_ string, err error) {
280279
returnl.Addr().String(),nil
281280
}
282281

283-
functempJSONFile(vinterface{}) (string,error) {
282+
functempJSONFile(vany) (string,error) {
284283
f,err:=os.CreateTemp("","temp.json")
285284
iferr!=nil {
286285
return"",fmt.Errorf("temp file: %w",err)

‎close.go‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build !js
2-
// +build !js
32

43
package websocket
54

‎close_test.go‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build !js
2-
// +build !js
32

43
package websocket
54

‎compress.go‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build !js
2-
// +build !js
32

43
package websocket
54

@@ -168,8 +167,10 @@ type slidingWindow struct {
168167
buf []byte
169168
}
170169

171-
varswPoolMu sync.RWMutex
172-
varswPool=map[int]*sync.Pool{}
170+
var (
171+
swPoolMu sync.RWMutex
172+
swPool=map[int]*sync.Pool{}
173+
)
173174

174175
funcslidingWindowPool(nint)*sync.Pool {
175176
swPoolMu.RLock()

‎compress_test.go‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build !js
2-
// +build !js
32

43
package websocket
54

@@ -19,7 +18,7 @@ func Test_slidingWindow(t *testing.T) {
1918

2019
consttestCount=99
2120
constmaxWindow=99999
22-
fori:=0;i<testCount;i++ {
21+
forrangetestCount {
2322
t.Run("",func(t*testing.T) {
2423
t.Parallel()
2524

‎conn.go‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build !js
2-
// +build !js
32

43
package websocket
54

‎conn_test.go‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func TestConn(t *testing.T) {
3636
returnwebsocket.CompressionMode(xrand.Int(int(websocket.CompressionContextTakeover)+1))
3737
}
3838

39-
fori:=0;i<5;i++ {
39+
forrange5 {
4040
t.Run("",func(t*testing.T) {
4141
tt,c1,c2:=newConnTest(t,&websocket.DialOptions{
4242
CompressionMode:compressionMode(),
@@ -50,7 +50,7 @@ func TestConn(t *testing.T) {
5050

5151
c1.SetReadLimit(131072)
5252

53-
fori:=0;i<5;i++ {
53+
forrange5 {
5454
err:=wstest.Echo(tt.ctx,c1,131072)
5555
assert.Success(t,err)
5656
}
@@ -76,7 +76,7 @@ func TestConn(t *testing.T) {
7676
c1.CloseRead(tt.ctx)
7777
c2.CloseRead(tt.ctx)
7878

79-
fori:=0;i<10;i++ {
79+
forrange10 {
8080
err:=c1.Ping(tt.ctx)
8181
assert.Success(t,err)
8282
}
@@ -185,7 +185,7 @@ func TestConn(t *testing.T) {
185185
constcount=100
186186
errs:=make(chanerror,count)
187187

188-
fori:=0;i<count;i++ {
188+
forrangecount {
189189
gofunc() {
190190
select {
191191
caseerrs<-c1.Write(tt.ctx,websocket.MessageBinary,msg):
@@ -195,7 +195,7 @@ func TestConn(t *testing.T) {
195195
}()
196196
}
197197

198-
fori:=0;i<count;i++ {
198+
forrangecount {
199199
select {
200200
caseerr:=<-errs:
201201
assert.Success(t,err)
@@ -341,7 +341,7 @@ func TestConn(t *testing.T) {
341341
returnwsjson.Write(tt.ctx,c1,exp)
342342
})
343343

344-
varactinterface{}
344+
varactany
345345
err:=wsjson.Read(tt.ctx,c1,&act)
346346
assert.Success(t,err)
347347
assert.Equal(t,"read msg",exp,act)
@@ -372,7 +372,7 @@ func TestConn(t *testing.T) {
372372
returnwsjson.Write(tt.ctx,c1,exp)
373373
})
374374

375-
varactinterface{}
375+
varactany
376376
err:=wsjson.Read(tt.ctx,c1,&act)
377377
assert.Success(t,err)
378378
assert.Equal(t,"read msg",exp,act)
@@ -408,7 +408,7 @@ func TestConn(t *testing.T) {
408408

409409
c1.SetReadLimit(131072)
410410

411-
fori:=0;i<5;i++ {
411+
forrange5 {
412412
err:=wstest.Echo(tt.ctx,c1,131072)
413413
assert.Success(t,err)
414414
}
@@ -660,7 +660,7 @@ func assertEcho(tb testing.TB, ctx context.Context, c *websocket.Conn) {
660660
returnwsjson.Write(ctx,c,exp)
661661
})
662662

663-
varactinterface{}
663+
varactany
664664
c.SetReadLimit(1<<30)
665665
err:=wsjson.Read(ctx,c,&act)
666666
assert.Success(tb,err)
@@ -682,7 +682,7 @@ func assertClose(tb testing.TB, c *websocket.Conn) {
682682

683683
funcTestConcurrentClosePing(t*testing.T) {
684684
t.Parallel()
685-
fori:=0;i<64;i++ {
685+
forrange64 {
686686
func() {
687687
c1,c2:=wstest.Pipe(nil,nil)
688688
deferc1.CloseNow()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp