You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At present, if you want to declare a specific implementation of an interface, you have to write a long fully qualified package name, which is very cumbersome. for example:
It is expected that aliases are added to interfaces through annotations, and then development is simplified by specifying aliases directly where needed.
Among them, it should be noted that:
Aliases are globally unique
When parsing aliases through CLI and then initiating alias registration, you need to pay attention to the timing of registration and use (sequence)
Thanks for your proposal @photowey , I have a question that, can we change ioc:autowire:service:alias to ioc:autowire:alias ? Like struct alias that already supported?
I think this is achievable, however, there are a few things to keep in mind:
Are aliases for interfaces and aliases for instances allowed to be duplicated?
How to distinguish whether an alias is an interface alias or an instance alias?
Suggest:
When registering an interface(Service) alias, we can add a special token, such as: "&"
// +ioc:autowire:alias=HelloServicetypeServiceinterface {
GetHelloString(string) string
}
// HelloService == github.com/alibaba/ioc-golang/example/autowire/autowire_active_profile_implements/service.Service// aliasMap// aliasMap["&HelloService"] = github.com/alibaba/ioc-golang/example/autowire/autowire_active_profile_implements/service.Service// Notes:// KEYs starting with "&" default to the KEY of the interface alias
At present, if you want to declare a specific implementation of an interface, you have to write a long fully qualified package name, which is very cumbersome. for example:
It is expected that aliases are added to interfaces through annotations, and then development is simplified by specifying aliases directly where needed.
Among them, it should be noted that:
CLI
and then initiating alias registration, you need to pay attention to the timing of registration and use (sequence)The effect achieved is as follows:
The text was updated successfully, but these errors were encountered: