Skip to content

Commit fe82f4e

Browse files
authored
chore: bump minimum go version to 1.24 and modernize (#61)
The results of running go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -fix -test ./... See modernize analyzer docs[1] for more info. [1]: https://pkg.go.dev/golang.org/x/tools/gopls/internal/analysis/modernize
1 parent e5e264c commit fe82f4e

File tree

4 files changed

+6
-17
lines changed

4 files changed

+6
-17
lines changed

autobahn_test.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import (
3636
"path/filepath"
3737
"regexp"
3838
"runtime"
39+
"slices"
3940
"strings"
4041
"testing"
4142
"time"
@@ -155,7 +156,6 @@ func TestAutobahn(t *testing.T) {
155156
}
156157

157158
for _, result := range summary {
158-
result := result
159159
t.Run("autobahn/"+result.ID, func(t *testing.T) {
160160
if result.Failed() {
161161
report := loadReport(t, testDir, result.ReportFile)
@@ -214,17 +214,12 @@ func newAutobahnTargetURL(t *testing.T, targetURL string) string {
214214

215215
func isLocalhost(ipAddr string) bool {
216216
ipAddr = strings.ToLower(ipAddr)
217-
for _, addr := range []string{
217+
return slices.Contains([]string{
218218
"localhost",
219219
"127.0.0.1",
220220
"::1",
221221
"0:0:0:0:0:0:0:1",
222-
} {
223-
if ipAddr == addr {
224-
return true
225-
}
226-
}
227-
return false
222+
}, ipAddr)
228223
}
229224

230225
func runCmd(t *testing.T, cmd *exec.Cmd) {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module github.com/mccutchen/websocket
22

3-
go 1.22.0
3+
go 1.24.0

proto_test.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ func TestRSV(t *testing.T) {
8383
},
8484
}
8585
for name, tc := range testCases {
86-
tc := tc
8786
t.Run(name, func(t *testing.T) {
8887
t.Parallel()
8988
buf := bytes.NewReader(tc.rawBytes)
@@ -145,7 +144,6 @@ func TestExampleFramesFromRFC(t *testing.T) {
145144
}
146145

147146
for name, tc := range testCases {
148-
tc := tc
149147
t.Run(name, func(t *testing.T) {
150148
t.Parallel()
151149
buf := bytes.NewReader(tc.rawBytes)
@@ -179,7 +177,6 @@ func TestIncompleteFrames(t *testing.T) {
179177
}
180178

181179
for name, tc := range testCases {
182-
tc := tc
183180
t.Run(name, func(t *testing.T) {
184181
t.Parallel()
185182
buf := bytes.NewReader(tc.rawBytes)
@@ -209,7 +206,7 @@ func BenchmarkReadFrame(b *testing.B) {
209206
src := bytes.NewReader(buf.Bytes())
210207
b.SetBytes(int64(buf.Len()))
211208
b.ResetTimer()
212-
for i := 0; i < b.N; i++ {
209+
for b.Loop() {
213210
_, _ = src.Seek(0, 0)
214211
frame2, err := websocket.ReadFrame(src, websocket.ServerMode, size)
215212
if err != nil {
@@ -234,7 +231,7 @@ func BenchmarkWriteFrame(b *testing.B) {
234231
b.SetBytes(int64(expectedSize))
235232
b.ResetTimer()
236233

237-
for i := 0; i < b.N; i++ {
234+
for b.Loop() {
238235
buf.Reset()
239236
assert.NilError(b, websocket.WriteFrame(buf, mask, frame))
240237
assert.Equal(b, buf.Len(), expectedSize, "payload length")

websocket_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ func TestHandshake(t *testing.T) {
117117
},
118118
}
119119
for name, tc := range testCases {
120-
tc := tc
121120
t.Run(name, func(t *testing.T) {
122121
t.Parallel()
123122

@@ -563,7 +562,6 @@ func TestProtocolErrors(t *testing.T) {
563562
},
564563
}
565564
for name, tc := range testCases {
566-
tc := tc
567565
if tc.opts == nil {
568566
tc.opts = newOpts
569567
}
@@ -629,7 +627,6 @@ func TestCloseFrames(t *testing.T) {
629627
}
630628

631629
for name, tc := range testCases {
632-
tc := tc
633630
t.Run(name, func(t *testing.T) {
634631
conn := setupRawConn(t, websocket.Options{})
635632
t.Logf("sending close frame %v", tc.frame)

0 commit comments

Comments
 (0)