@@ -97,15 +97,13 @@ func TestSync_ConcurrentPuts(t *testing.T) {
9797 errCount := make (chan struct {}, numWrites )
9898
9999 for i := 0 ; i < numWrites ; i ++ {
100- wg .Add (1 )
101- go func (i int ) {
102- defer wg .Done ()
100+ wg .Go (func () {
103101 key := []byte (fmt .Sprintf ("key-%d" , i ))
104102 value := fmt .Sprintf ("value-%d" , i )
105103 if err := client .Put (ctx , key , []byte (value )); err != nil {
106104 errCount <- struct {}{}
107105 }
108- }( i )
106+ })
109107 }
110108
111109 wg .Wait ()
@@ -437,17 +435,15 @@ func TestMultiClient_ConcurrentWrites(t *testing.T) {
437435 // Each client writes its own set of keys concurrently
438436 var wg sync.WaitGroup
439437 for clientID := 0 ; clientID < numClients ; clientID ++ {
440- wg .Add (1 )
441- go func (clientID int ) {
442- defer wg .Done ()
438+ wg .Go (func () {
443439 client := clients [clientID ]
444440 for i := 0 ; i < writesPerClient ; i ++ {
445441 key := []byte (fmt .Sprintf ("client%d-key%d" , clientID , i ))
446442 value := []byte (fmt .Sprintf ("client%d-value%d" , clientID , i ))
447443 err := client .Put (ctx , key , value )
448444 require .NoError (t , err )
449445 }
450- }( clientID )
446+ })
451447 }
452448
453449 wg .Wait ()
@@ -579,11 +575,8 @@ func TestSync_StressReadYourOwnWrites(t *testing.T) {
579575 var totalOps atomic.Int64
580576 var wg sync.WaitGroup
581577
582- for p := 0 ; p < numProducers ; p ++ {
583- wg .Add (1 )
584- go func (producerID int ) {
585- defer wg .Done ()
586-
578+ for producerID := 0 ; producerID < numProducers ; producerID ++ {
579+ wg .Go (func () {
587580 // Each producer has its own key - no concurrent writes to same key
588581 key := []byte (fmt .Sprintf ("producer-%d-key" , producerID ))
589582
@@ -618,7 +611,7 @@ func TestSync_StressReadYourOwnWrites(t *testing.T) {
618611
619612 totalOps .Add (1 )
620613 }
621- }( p )
614+ })
622615 }
623616
624617 wg .Wait ()
0 commit comments