代码拉取完成,页面将自动刷新
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)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。