@@ -372,7 +372,7 @@ func (b *Binding) getOrPrepareReceiver(value reflect.Value) (*receiver, error) {
372
372
return nil , b .bindErrFactory (errExprSelector .String (), errMsg )
373
373
}
374
374
if ! recv .hasVd {
375
- recv .hasVd , _ = b .findVdTag (ameda .DereferenceType (t ), false , 20 )
375
+ recv .hasVd , _ = b .findVdTag (ameda .DereferenceType (t ), false , 20 , map [reflect. Type ] bool {} )
376
376
}
377
377
recv .initParams ()
378
378
@@ -383,13 +383,14 @@ func (b *Binding) getOrPrepareReceiver(value reflect.Value) (*receiver, error) {
383
383
return recv , nil
384
384
}
385
385
386
- func (b * Binding ) findVdTag (t reflect.Type , inMapOrSlice bool , depth int ) (hasVd bool , err error ) {
387
- if depth <= 0 {
386
+ func (b * Binding ) findVdTag (t reflect.Type , inMapOrSlice bool , depth int , exist map [reflect. Type ] bool ) (hasVd bool , err error ) {
387
+ if depth <= 0 || exist [ t ] {
388
388
return
389
389
}
390
390
depth --
391
391
switch t .Kind () {
392
392
case reflect .Struct :
393
+ exist [t ] = true
393
394
for i := t .NumField () - 1 ; i >= 0 ; i -- {
394
395
field := t .Field (i )
395
396
if inMapOrSlice {
@@ -400,14 +401,14 @@ func (b *Binding) findVdTag(t reflect.Type, inMapOrSlice bool, depth int) (hasVd
400
401
}
401
402
}
402
403
}
403
- hasVd , _ = b .findVdTag (ameda .DereferenceType (field .Type ), inMapOrSlice , depth )
404
+ hasVd , _ = b .findVdTag (ameda .DereferenceType (field .Type ), inMapOrSlice , depth , exist )
404
405
if hasVd {
405
406
return true , nil
406
407
}
407
408
}
408
409
return false , nil
409
410
case reflect .Slice , reflect .Array , reflect .Map :
410
- return b .findVdTag (ameda .DereferenceType (t .Elem ()), true , depth )
411
+ return b .findVdTag (ameda .DereferenceType (t .Elem ()), true , depth , exist )
411
412
default :
412
413
return false , nil
413
414
}
0 commit comments