diff --git a/pkg/schedule/checker/checker_controller.go b/pkg/schedule/checker/checker_controller.go index 9c9ae8fbed61..3b59d860e607 100644 --- a/pkg/schedule/checker/checker_controller.go +++ b/pkg/schedule/checker/checker_controller.go @@ -521,7 +521,7 @@ func (p *PatrolRegionContext) stop() { } func (p *PatrolRegionContext) startPatrolRegionWorkers(c *Controller) { - for i := 0; i < c.workerCount; i++ { + for i := range c.workerCount { p.wg.Add(1) go func(i int) { defer logutil.LogPanic() diff --git a/server/cluster/cluster_test.go b/server/cluster/cluster_test.go index b8f55bcb4945..fdba7349ca4a 100644 --- a/server/cluster/cluster_test.go +++ b/server/cluster/cluster_test.go @@ -2934,12 +2934,12 @@ func TestPatrolRegionConcurrency(t *testing.T) { checker := co.GetCheckerController() tc.opt.SetSplitMergeInterval(time.Duration(0)) - for i := 1; i < 4; i++ { - if err := tc.addRegionStore(uint64(i), regionNum); err != nil { + for i := range 3 { + if err := tc.addRegionStore(uint64(i+1), regionNum); err != nil { return } } - for i := 0; i < regionNum; i++ { + for i := range regionNum { if err := tc.addLeaderRegion(uint64(i), 1, 2, 3); err != nil { return } @@ -2955,7 +2955,7 @@ func TestPatrolRegionConcurrency(t *testing.T) { // test patrol region concurrency with suspect regions suspectRegions := make([]uint64, 0) - for i := 0; i < 10; i++ { + for i := range 10 { suspectRegions = append(suspectRegions, uint64(i)) } checker.AddPendingProcessedRegions(false, suspectRegions...)