diff --git a/client/history/client.go b/client/history/client.go index 760edf21abc..cf41bb26bb9 100644 --- a/client/history/client.go +++ b/client/history/client.go @@ -754,7 +754,6 @@ func (c *clientImpl) GetReplicationMessages( peerResponses := make([]*getReplicationMessagesWithSize, 0, len(requestsByPeer)) for peer, req := range requestsByPeer { - peer, req := peer, req g.Go(func() (e error) { defer func() { log.CapturePanic(recover(), c.logger, &e) }() @@ -929,7 +928,6 @@ func (c *clientImpl) CountDLQMessages( g := &errgroup.Group{} for _, peer := range peers { - peer := peer g.Go(func() (e error) { defer func() { log.CapturePanic(recover(), c.logger, &e) }() @@ -1035,7 +1033,6 @@ func (c *clientImpl) NotifyFailoverMarkers( g := &errgroup.Group{} for peer, req := range requestsByPeer { - peer, req := peer, req g.Go(func() (e error) { defer func() { log.CapturePanic(recover(), c.logger, &e) }() return c.client.NotifyFailoverMarkers(ctx, req, append(opts, yarpc.WithShardKey(peer))...) diff --git a/client/history/client_test.go b/client/history/client_test.go index f977d082408..cb3fbbd36a1 100644 --- a/client/history/client_test.go +++ b/client/history/client_test.go @@ -942,7 +942,6 @@ func TestClient_withResponse(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() @@ -1279,7 +1278,6 @@ func TestClient_withNoResponse(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { ctrl := gomock.NewController(t) defer ctrl.Finish() diff --git a/client/history/peer_resolver_test.go b/client/history/peer_resolver_test.go index 72bd837eba9..d643fb7c53e 100644 --- a/client/history/peer_resolver_test.go +++ b/client/history/peer_resolver_test.go @@ -132,7 +132,6 @@ func TestPeerResolver(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { controller := gomock.NewController(t) serviceResolver := membership.NewMockResolver(controller) @@ -205,7 +204,6 @@ func TestPeerResolver(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { controller := gomock.NewController(t) serviceResolver := membership.NewMockResolver(controller) diff --git a/client/matching/client_test.go b/client/matching/client_test.go index 88d1cecd23e..dec680f0783 100644 --- a/client/matching/client_test.go +++ b/client/matching/client_test.go @@ -134,7 +134,6 @@ func TestClient_withoutResponse(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { // setting up client @@ -534,7 +533,6 @@ func TestClient_withResponse(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { // setting up client diff --git a/common/clock/ratelimiter_comparison_test.go b/common/clock/ratelimiter_comparison_test.go index 091efc95516..c94ee73006a 100644 --- a/common/clock/ratelimiter_comparison_test.go +++ b/common/clock/ratelimiter_comparison_test.go @@ -330,9 +330,7 @@ func assertRatelimitersBehaveSimilarly(t *testing.T, burst int, minWaitDuration ticker := time.NewTicker(fuzzGranularity) defer ticker.Stop() for round := range schedule { - round := round // for closure for event := range schedule[round] { - event := event // for closure <-ticker.C ts.Advance(fuzzGranularity) // may also be advanced inside wait debugLogf(t, "Tokens before round, real: %0.2f, wrapped: %0.2f, mocked: %0.2f", actual.Tokens(), wrapped.Tokens(), mocked.Tokens()) diff --git a/common/clock/ratelimiter_test.go b/common/clock/ratelimiter_test.go index d3bd68dbbf3..64320f5a5df 100644 --- a/common/clock/ratelimiter_test.go +++ b/common/clock/ratelimiter_test.go @@ -39,7 +39,6 @@ func TestRatelimiter(t *testing.T) { t.Parallel() for _, name := range []string{"real", "mocked"} { - name := name t.Run(name, func(t *testing.T) { t.Parallel() ts := func() MockedTimeSource { return nil } @@ -250,7 +249,6 @@ func assertRatelimiterBasicsWork(t *testing.T, makeTimesource func() MockedTimeS tokenChange: -2, // would be -3 if it went negative }, } { - name, tc := name, tc t.Run(name, func(t *testing.T) { t.Parallel() ts := makeTimesource() @@ -401,7 +399,6 @@ func assertRatelimiterBasicsWork(t *testing.T, makeTimesource func() MockedTimeS tokenChange: 0.5, // only waited for half an event -> recovered half a token }, } { - name, tc := name, tc t.Run(name, func(t *testing.T) { t.Parallel() ts := makeTimesource() diff --git a/common/peerprovider/ringpopprovider/provider_test.go b/common/peerprovider/ringpopprovider/provider_test.go index ba45742fa45..d7dfc3b6348 100644 --- a/common/peerprovider/ringpopprovider/provider_test.go +++ b/common/peerprovider/ringpopprovider/provider_test.go @@ -81,7 +81,6 @@ func TestRingpopProvider(t *testing.T) { // start ringpop provider for each channel var wg sync.WaitGroup for i, svc := range allServicesAndChs { - svc := svc cfg := cfg if i == 0 { // set broadcast address for the first provider to test that path diff --git a/common/persistence/client/bean_test.go b/common/persistence/client/bean_test.go index 0d719c19c26..21670565c09 100644 --- a/common/persistence/client/bean_test.go +++ b/common/persistence/client/bean_test.go @@ -131,7 +131,6 @@ func TestBeanCoverage(t *testing.T) { }, } for name, test := range tests { - name, test := name, test t.Run(name, func(t *testing.T) { t.Parallel() f, _, defaultMocks := beanSetup(t) diff --git a/common/persistence/serializer_test.go b/common/persistence/serializer_test.go index 18b936e8b7d..187772659f6 100644 --- a/common/persistence/serializer_test.go +++ b/common/persistence/serializer_test.go @@ -275,7 +275,6 @@ func TestSerializers(t *testing.T) { } for _, tc := range runnableTests { - tc := tc t.Run(fmt.Sprintf("%s with encoding:%s,payload:%s", tc.name, tc.encoding, tc.payloadName), func(t *testing.T) { t.Parallel() diff --git a/common/quotas/global/collection/collection_test.go b/common/quotas/global/collection/collection_test.go index 7c4f0554d93..df844e970d9 100644 --- a/common/quotas/global/collection/collection_test.go +++ b/common/quotas/global/collection/collection_test.go @@ -116,7 +116,6 @@ func TestCollectionLimitersCollectMetrics(t *testing.T) { } for name, test := range tests { - test := test t.Run(name, func(t *testing.T) { t.Parallel() @@ -464,7 +463,6 @@ func TestBoostRPS(t *testing.T) { }, } for name, tc := range tests { - name, tc := name, tc t.Run(name, func(t *testing.T) { t.Parallel() assert.GreaterOrEqual(t, tc.weight, float64(0), "sanity check on weight") diff --git a/common/quotas/global/collection/internal/shadowed_test.go b/common/quotas/global/collection/internal/shadowed_test.go index afc4531174a..eec62cda78f 100644 --- a/common/quotas/global/collection/internal/shadowed_test.go +++ b/common/quotas/global/collection/internal/shadowed_test.go @@ -74,7 +74,6 @@ func TestShadowed(t *testing.T) { }, } for name, test := range tests { - test := test t.Run("allow-"+name, func(t *testing.T) { ts := clock.NewMockedTimeSource() primaryBurst, shadowBurst := 0, 0 diff --git a/common/quotas/global/rpc/client.go b/common/quotas/global/rpc/client.go index 2f74c5737a5..54ec36970b2 100644 --- a/common/quotas/global/rpc/client.go +++ b/common/quotas/global/rpc/client.go @@ -139,7 +139,6 @@ func (c *client) Update(ctx context.Context, period time.Duration, load map[shar // but as each goes to a different host this seems fine to just blast out all at once, // and it makes timeouts easy because we don't need to reserve room for queued calls. for peer, peerKeys := range peers { - peer, peerKeys := peer, peerKeys // for closure g.Go(func() (err error) { defer func() { log.CapturePanic(recover(), c.logger, &err) }() diff --git a/common/quotas/global/rpc/mapping_test.go b/common/quotas/global/rpc/mapping_test.go index 07f4a00a016..7e12ce4eb9b 100644 --- a/common/quotas/global/rpc/mapping_test.go +++ b/common/quotas/global/rpc/mapping_test.go @@ -154,7 +154,6 @@ func TestMapping(t *testing.T) { }, } for name, test := range tests { - test := test t.Run(name, func(t *testing.T) { require.ErrorContains(t, test.do(test.value), test.errContains) }) diff --git a/common/quotas/global/shared/sanity_test.go b/common/quotas/global/shared/sanity_test.go index 6407508a894..f4f55ba54fa 100644 --- a/common/quotas/global/shared/sanity_test.go +++ b/common/quotas/global/shared/sanity_test.go @@ -49,7 +49,6 @@ func TestSanityChecks(t *testing.T) { "inclusive upper": {lower: 0, actual: 10, upper: 10, expected: ""}, } for name, test := range tests { - name, test := name, test t.Run(name, func(t *testing.T) { msg := SanityCheckFloat(test.lower, test.actual, test.upper, "test") if test.expected == "" { diff --git a/common/types/admin_test.go b/common/types/admin_test.go index f0bb1b266a5..128a496f595 100644 --- a/common/types/admin_test.go +++ b/common/types/admin_test.go @@ -112,7 +112,6 @@ func TestIsolationGroupConfigurationDeepCopy(t *testing.T) { }, } for _, tc := range tests { - tc := tc t.Run(tc.name, func(t *testing.T) { got := tc.input.DeepCopy() assert.Equal(t, tc.input, got) @@ -157,7 +156,6 @@ func TestAsyncWorkflowConfigurationDeepCopy(t *testing.T) { } for _, tc := range tests { - tc := tc t.Run(tc.name, func(t *testing.T) { got := tc.input.DeepCopy() assert.Equal(t, tc.input, got) diff --git a/common/types/shared_test.go b/common/types/shared_test.go index 927064c0662..5549ead413c 100644 --- a/common/types/shared_test.go +++ b/common/types/shared_test.go @@ -60,7 +60,6 @@ func TestDataBlobDeepCopy(t *testing.T) { } for _, tc := range tests { - tc := tc t.Run(tc.name, func(t *testing.T) { got := tc.input.DeepCopy() assert.Equal(t, tc.input, got) diff --git a/service/history/execution/mutable_state_util.go b/service/history/execution/mutable_state_util.go index 8d8d18fcf33..9775319efbe 100644 --- a/service/history/execution/mutable_state_util.go +++ b/service/history/execution/mutable_state_util.go @@ -74,7 +74,6 @@ func convertSyncActivityInfos( func convertWorkflowRequests(inputs map[persistence.WorkflowRequest]struct{}) []*persistence.WorkflowRequest { outputs := make([]*persistence.WorkflowRequest, 0, len(inputs)) for key := range inputs { - key := key // TODO: remove this trick once we upgrade go to 1.22 outputs = append(outputs, &key) } return outputs diff --git a/service/history/handler/handler.go b/service/history/handler/handler.go index 19888065aca..71cef91840c 100644 --- a/service/history/handler/handler.go +++ b/service/history/handler/handler.go @@ -1871,7 +1871,6 @@ func (h *handlerImpl) CountDLQMessages( var mu sync.Mutex entries := map[types.HistoryDLQCountKey]int64{} for _, shardID := range h.controller.ShardIDs() { - shardID := shardID g.Go(func() (e error) { defer func() { log.CapturePanic(recover(), h.GetLogger(), &e) }() diff --git a/service/matching/tasklist/matcher_test.go b/service/matching/tasklist/matcher_test.go index 248451990ae..9a88d1ed74b 100644 --- a/service/matching/tasklist/matcher_test.go +++ b/service/matching/tasklist/matcher_test.go @@ -1387,7 +1387,7 @@ func TestRatelimitBehavior(t *testing.T) { }, } for name, test := range tests { - test := test // closure copy + // closure copy t.Run(name, func(t *testing.T) { t.Parallel() check := func(t *testing.T, allow func() bool, allowable func(ctx context.Context) (*rate.Reservation, error)) { diff --git a/service/matching/tasklist/task_reader.go b/service/matching/tasklist/task_reader.go index 98b78484909..c4d907fe153 100644 --- a/service/matching/tasklist/task_reader.go +++ b/service/matching/tasklist/task_reader.go @@ -134,7 +134,6 @@ func newTaskReader(tlMgr *taskListManagerImpl, isolationGroups []string) *taskRe func (tr *taskReader) Start() { tr.Signal() for g := range tr.taskBuffers { - g := g tr.stopWg.Add(1) go func() { defer tr.stopWg.Done() diff --git a/simulation/replication/replication_simulation_test.go b/simulation/replication/replication_simulation_test.go index 02cac9b4167..f21fe8aa993 100644 --- a/simulation/replication/replication_simulation_test.go +++ b/simulation/replication/replication_simulation_test.go @@ -84,7 +84,6 @@ func TestReplicationSimulation(t *testing.T) { startTime := time.Now().UTC() simTypes.Logf(t, "Simulation start time: %v", startTime) for i, op := range simCfg.Operations { - op := op waitForOpTime(t, op, startTime) var err error switch op.Type { diff --git a/simulation/replication/worker/cmd/main.go b/simulation/replication/worker/cmd/main.go index c65bda22a22..af51391f8b4 100644 --- a/simulation/replication/worker/cmd/main.go +++ b/simulation/replication/worker/cmd/main.go @@ -112,7 +112,6 @@ func main() { wg := sync.WaitGroup{} for domainName := range simCfg.Domains { - domainName := domainName wg.Add(1) go func() { diff --git a/tools/cli/admin_db_decode_thrift_test.go b/tools/cli/admin_db_decode_thrift_test.go index df0e9f979a6..d71bf6c51ca 100644 --- a/tools/cli/admin_db_decode_thrift_test.go +++ b/tools/cli/admin_db_decode_thrift_test.go @@ -117,7 +117,6 @@ func TestThriftDecodeHelper(t *testing.T) { } for _, tc := range tests { - tc := tc t.Run(tc.desc, func(t *testing.T) { t.Parallel() data, err := decodeUserInput(tc.input, tc.encoding)