Skip to content

Commit 4b91caf

Browse files
committed
fix: intrange recommendations - refactor loops
Signed-off-by: Mike Nguyen <[email protected]>
1 parent 6f79543 commit 4b91caf

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

actor/manager/manager.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ var ignoredActorMethods = []string{"Type"}
3737
// init initializes the action method exclusion list with methods from ServerImplBaseCtx and ReminderCallee interfaces.
3838
func init() {
3939
serverImplBaseCtxType := reflect.TypeOf(&actor.ServerImplBaseCtx{})
40-
for i := 0; i < serverImplBaseCtxType.NumMethod(); i++ {
40+
for i := range serverImplBaseCtxType.NumMethod() {
4141
ignoredActorMethods = append(ignoredActorMethods, serverImplBaseCtxType.Method(i).Name)
4242
}
4343
ReminderCallType := reflect.TypeOf((*actor.ReminderCallee)(nil)).Elem()
44-
for i := 0; i < ReminderCallType.NumMethod(); i++ {
44+
for i := range ReminderCallType.NumMethod() {
4545
ignoredActorMethods = append(ignoredActorMethods, ReminderCallType.Method(i).Name)
4646
}
4747
}
@@ -265,7 +265,7 @@ type MethodType struct {
265265
// suitableMethods returns suitable Rpc methods of typ.
266266
func suitableMethods(typ reflect.Type) map[string]*MethodType {
267267
methods := make(map[string]*MethodType)
268-
for m := 0; m < typ.NumMethod(); m++ {
268+
for m := range typ.NumMethod() {
269269
method := typ.Method(m)
270270
// skip methods from ServerImplBaseCtx struct and ServerContext and ReminderCallee interfaces.
271271
if slices.Contains(ignoredActorMethods, method.Name) {

client/actor.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ func (c *GRPCClient) implActor(actor actor.Client, serializer codec.Codec) {
289289
}
290290

291291
numField := valueOfActor.NumField()
292-
for i := 0; i < numField; i++ {
292+
for i := range numField {
293293
t := typeOfActor.Field(i)
294294
methodName := t.Name
295295
if methodName == "Type" {
@@ -312,7 +312,7 @@ func (c *GRPCClient) implActor(actor actor.Client, serializer codec.Codec) {
312312
}
313313

314314
funcOuts := make([]reflect.Type, outNum)
315-
for i := 0; i < outNum; i++ {
315+
for i := range outNum {
316316
funcOuts[i] = t.Type.Out(i)
317317
}
318318

client/client_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ func (s *testDaprServer) SubscribeConfiguration(in *pb.SubscribeConfigurationReq
466466
return err
467467
}
468468

469-
for i := 0; i < 5; i++ {
469+
for range 5 {
470470
select {
471471
case <-stopCh:
472472
return nil

client/state.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ func (c *GRPCClient) DeleteBulkState(ctx context.Context, storeName string, keys
484484
}
485485

486486
items := make([]*DeleteStateItem, 0, len(keys))
487-
for i := 0; i < len(keys); i++ {
487+
for i := range keys {
488488
item := &DeleteStateItem{
489489
Key: keys[i],
490490
Metadata: meta,
@@ -502,7 +502,7 @@ func (c *GRPCClient) DeleteBulkStateItems(ctx context.Context, storeName string,
502502
}
503503

504504
states := make([]*v1.StateItem, 0, len(items))
505-
for i := 0; i < len(items); i++ {
505+
for i := range items {
506506
item := items[i]
507507
if err := hasRequiredStateArgs(storeName, item.Key); err != nil {
508508
return fmt.Errorf("missing required arguments: %w", err)

0 commit comments

Comments
 (0)