我从头到尾实现了一个Golang的依赖注入框架,并且集成了gin、xorm、redis、cron、消息中间件等功能;自己觉得还挺好用的,推荐给你!也欢迎一起维护!
github地址:https://github.com/gone-io/gone
文档地址:https://goner.fun/
如果可能,请帮忙在github上点个 ⭐️ ;万分感谢!!
如果被注入结构体的属性是一个指针,那么这个注入就是 指针注入;值注入 和接口注入 的定义也是类似的。让我们来举个例子:
type AGoner struct {
gone.Flag //tell the framework that this struct is a Goner
Name string
}
func (g *AGoner) Say() {
println("I am the AGoner, My name is"