Use modern WaitGroup.Go function in additional places

This commit is contained in:
Jesper Noordsij
2026-03-06 15:22:06 +01:00
committed by GitHub
parent 9ab7fb860d
commit c7d5507462
4 changed files with 5 additions and 12 deletions
-1
View File
@@ -515,7 +515,6 @@ func TestDifferentIntervals(t *testing.T) {
wg := sync.WaitGroup{} wg := sync.WaitGroup{}
wg.Go(func() { wg.Go(func() {
hc.Launch(ctx) hc.Launch(ctx)
wg.Done()
}) })
select { select {
+2 -4
View File
@@ -192,11 +192,9 @@ func TestBasicAuthConcurrentHashOnce(t *testing.T) {
defer ts.Close() defer ts.Close()
var wg sync.WaitGroup var wg sync.WaitGroup
wg.Add(2)
for range 2 { for range 2 {
go func() { wg.Go(func() {
defer wg.Done()
req := testhelpers.MustNewRequest(http.MethodGet, ts.URL, nil) req := testhelpers.MustNewRequest(http.MethodGet, ts.URL, nil)
req.SetBasicAuth("test", "test") req.SetBasicAuth("test", "test")
@@ -205,7 +203,7 @@ func TestBasicAuthConcurrentHashOnce(t *testing.T) {
defer res.Body.Close() defer res.Body.Close()
assert.Equal(t, http.StatusOK, res.StatusCode, "they should be equal") assert.Equal(t, http.StatusOK, res.StatusCode, "they should be equal")
}() })
} }
wg.Wait() wg.Wait()
-2
View File
@@ -51,8 +51,6 @@ func (eps UDPEntryPoints) Stop() {
for epn, ep := range eps { for epn, ep := range eps {
wg.Go(func() { wg.Go(func() {
defer wg.Done()
logger := log.With().Str(logs.EntryPointName, epn).Logger() logger := log.With().Str(logs.EntryPointName, epn).Logger()
ep.Shutdown(logger.WithContext(context.Background())) ep.Shutdown(logger.WithContext(context.Background()))
@@ -560,13 +560,11 @@ func TestConcurrentResponseTimeUpdates(t *testing.T) {
updatesPerGoroutine := 20 updatesPerGoroutine := 20
for i := range numGoroutines { for i := range numGoroutines {
wg.Add(1) wg.Go(func() {
go func(id int) {
defer wg.Done()
for range updatesPerGoroutine { for range updatesPerGoroutine {
handler.updateResponseTime(time.Duration(id+1) * time.Millisecond) handler.updateResponseTime(time.Duration(i+1) * time.Millisecond)
} }
}(i) })
} }
wg.Wait() wg.Wait()