Closed iyaozhen closed 4 months ago
This is embarrassing. 🫣
Let me think about it.
Аlso came across this
Seems to be solved by adding (Must)InvokeAsNamed
to support not only any.
It just invokeAnyByName().(T)
, but with cast check in package
I suppose do.InvokeNamed()
should be able to skip the type check when the type is any
?
I suppose
do.InvokeNamed()
should be able to skip the type check when the type isany
?
I think this is a good solution.
@d-enk in your PR you said we might add the behavior to AsNamed
. Can you tell us more about your though?
I don't see in what case we would declare an alias to any
.
I assumed. I just look at where invokeByName
(type check) is used.
https://github.com/samber/do/blob/1998a7a1b1a618eed087c91bc4932934355d5477/service_alias.go#L78-L79
No more reasons. Of course, it doesn't make sense until it's needed.
Thanks for the approval before 2.0
Demo(use v2):
do.InvokeNamed[any](nil, "test")
not workWhy do I have to do this?
I want to generic call my local service, I just known service name
invokeAnyByName
Is what I want, can you Export It ?thank you