#97 add As for all interface.
This commit is contained in:
parent
c09674ae92
commit
cdfeaa7e20
51
micro.go
51
micro.go
@ -33,25 +33,42 @@ func As(b any, target any) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
targetType := typ.Elem()
|
targetType := typ.Elem()
|
||||||
if targetType.Kind() != reflect.Interface &&
|
if targetType.Kind() != reflect.Interface {
|
||||||
!(targetType.Implements(brokerType) ||
|
switch {
|
||||||
targetType.Implements(loggerType) ||
|
case targetType.Implements(brokerType):
|
||||||
targetType.Implements(clientType) ||
|
break
|
||||||
targetType.Implements(serverType) ||
|
case targetType.Implements(loggerType):
|
||||||
targetType.Implements(codecType) ||
|
break
|
||||||
targetType.Implements(flowType) ||
|
case targetType.Implements(clientType):
|
||||||
targetType.Implements(fsmType) ||
|
break
|
||||||
targetType.Implements(meterType) ||
|
case targetType.Implements(serverType):
|
||||||
targetType.Implements(registerType) ||
|
break
|
||||||
targetType.Implements(resolverType) ||
|
case targetType.Implements(codecType):
|
||||||
targetType.Implements(selectorType) ||
|
break
|
||||||
targetType.Implements(storeType) ||
|
case targetType.Implements(flowType):
|
||||||
targetType.Implements(syncType) ||
|
break
|
||||||
targetType.Implements(tracerType) ||
|
case targetType.Implements(fsmType):
|
||||||
targetType.Implements(serviceType) ||
|
break
|
||||||
targetType.Implements(routerType)) {
|
case targetType.Implements(meterType):
|
||||||
|
break
|
||||||
|
case targetType.Implements(registerType):
|
||||||
|
break
|
||||||
|
case targetType.Implements(resolverType):
|
||||||
|
break
|
||||||
|
case targetType.Implements(selectorType):
|
||||||
|
break
|
||||||
|
case targetType.Implements(storeType):
|
||||||
|
break
|
||||||
|
case targetType.Implements(syncType):
|
||||||
|
break
|
||||||
|
case targetType.Implements(serviceType):
|
||||||
|
break
|
||||||
|
case targetType.Implements(routerType):
|
||||||
|
break
|
||||||
|
default:
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if reflect.TypeOf(b).AssignableTo(targetType) {
|
if reflect.TypeOf(b).AssignableTo(targetType) {
|
||||||
val.Elem().Set(reflect.ValueOf(b))
|
val.Elem().Set(reflect.ValueOf(b))
|
||||||
return true
|
return true
|
||||||
|
Loading…
Reference in New Issue
Block a user