1 Star 0 Fork 0

daheige/go-ddd-api

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
main.go 1.25 KB
一键复制 编辑 原始数据 按行查看 历史
daheige 提交于 2021-09-15 08:40 . Update main.go
package main
import (
"flag"
"log"
"github.com/go-god/gdi"
"github.com/go-god/gdi/factory"
"github.com/daheige/go-ddd-api/api"
"github.com/daheige/go-ddd-api/api/news"
"github.com/daheige/go-ddd-api/api/topics"
"github.com/daheige/go-ddd-api/internal/application"
"github.com/daheige/go-ddd-api/internal/infras/config"
"github.com/daheige/go-ddd-api/internal/infras/migration"
"github.com/daheige/go-ddd-api/internal/infras/persistence"
)
var port int
func init() {
flag.IntVar(&port, "port", 8000, "app run port,eg:8000")
flag.Parse()
}
func main() {
var app api.AppService
di := factory.CreateDI(factory.FbInject) // create a di container
err := di.Provide(
&gdi.Object{Value: &app},
&gdi.Object{Value: config.Init()},
&gdi.Object{Value: &migration.MigrateAction{}},
&gdi.Object{Value: &news.NewsHandler{}},
&gdi.Object{Value: &topics.TopicHandler{}},
&gdi.Object{Value: &application.TopicService{}},
&gdi.Object{Value: &application.NewsService{}},
&gdi.Object{Value: &persistence.NewsRepositoryImpl{}},
&gdi.Object{Value: &persistence.TopicRepositoryImpl{}},
)
if err != nil {
log.Fatalln("provide error: ", err)
}
err = di.Invoke()
if err != nil {
log.Fatalln("invoke error: ", err)
}
// app service run
app.Run(port)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/daheige/go-ddd-api.git
git@gitee.com:daheige/go-ddd-api.git
daheige
go-ddd-api
go-ddd-api
master

搜索帮助