Skip to content

Commit bbdfb42

Browse files
committed
test: migrate to wg.Go (Go 1.25)
1 parent 9b5335e commit bbdfb42

1 file changed

Lines changed: 10 additions & 20 deletions

File tree

tests/headers_plugin_test.go

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,10 @@ func TestHeadersInit(t *testing.T) {
4949
signal.Notify(sig, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
5050

5151
wg := &sync.WaitGroup{}
52-
wg.Add(1)
5352

5453
stopCh := make(chan struct{}, 1)
5554

56-
go func() {
57-
defer wg.Done()
55+
wg.Go(func() {
5856
for {
5957
select {
6058
case e := <-ch:
@@ -78,7 +76,7 @@ func TestHeadersInit(t *testing.T) {
7876
return
7977
}
8078
}
81-
}()
79+
})
8280

8381
time.Sleep(time.Second)
8482
stopCh <- struct{}{}
@@ -114,12 +112,10 @@ func TestRequestHeaders(t *testing.T) {
114112
signal.Notify(sig, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
115113

116114
wg := &sync.WaitGroup{}
117-
wg.Add(1)
118115

119116
stopCh := make(chan struct{}, 1)
120117

121-
go func() {
122-
defer wg.Done()
118+
wg.Go(func() {
123119
for {
124120
select {
125121
case e := <-ch:
@@ -143,7 +139,7 @@ func TestRequestHeaders(t *testing.T) {
143139
return
144140
}
145141
}
146-
}()
142+
})
147143

148144
time.Sleep(time.Second)
149145
t.Run("RequestHeaders", reqHeaders)
@@ -198,12 +194,10 @@ func TestResponseHeaders(t *testing.T) {
198194
signal.Notify(sig, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
199195

200196
wg := &sync.WaitGroup{}
201-
wg.Add(1)
202197

203198
stopCh := make(chan struct{}, 1)
204199

205-
go func() {
206-
defer wg.Done()
200+
wg.Go(func() {
207201
for {
208202
select {
209203
case e := <-ch:
@@ -227,7 +221,7 @@ func TestResponseHeaders(t *testing.T) {
227221
return
228222
}
229223
}
230-
}()
224+
})
231225

232226
time.Sleep(time.Second)
233227
t.Run("ResponseHeaders", resHeaders)
@@ -283,12 +277,10 @@ func TestCORSHeaders(t *testing.T) {
283277
signal.Notify(sig, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
284278

285279
wg := &sync.WaitGroup{}
286-
wg.Add(1)
287280

288281
stopCh := make(chan struct{}, 1)
289282

290-
go func() {
291-
defer wg.Done()
283+
wg.Go(func() {
292284
for {
293285
select {
294286
case e := <-ch:
@@ -312,7 +304,7 @@ func TestCORSHeaders(t *testing.T) {
312304
return
313305
}
314306
}
315-
}()
307+
})
316308

317309
time.Sleep(time.Second)
318310
t.Run("CORSHeaders", corsHeaders("*"))
@@ -351,12 +343,10 @@ func TestCORSHeadersRegex(t *testing.T) {
351343
signal.Notify(sig, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
352344

353345
wg := &sync.WaitGroup{}
354-
wg.Add(1)
355346

356347
stopCh := make(chan struct{}, 1)
357348

358-
go func() {
359-
defer wg.Done()
349+
wg.Go(func() {
360350
for {
361351
select {
362352
case e := <-ch:
@@ -380,7 +370,7 @@ func TestCORSHeadersRegex(t *testing.T) {
380370
return
381371
}
382372
}
383-
}()
373+
})
384374

385375
time.Sleep(time.Second)
386376
t.Run("CORSHeaders", corsHeaders("http://127.0.0.1:10"))

0 commit comments

Comments
 (0)