diff --git a/api/internal/svc/servicecontext.go b/api/internal/svc/servicecontext.go index 2a20ab4c..c4157626 100644 --- a/api/internal/svc/servicecontext.go +++ b/api/internal/svc/servicecontext.go @@ -77,11 +77,15 @@ func NewServiceContext(c config.Config) *ServiceContext { downloader := s3manager.NewDownloader(session) uploader := s3manager.NewUploader(session) //启动Gorm支持 - dbEngin, _ := gorm.Open(mysql.Open(c.DB.DataSource), &gorm.Config{ + dbEngin, err := gorm.Open(mysql.Open(c.DB.DataSource), &gorm.Config{ NamingStrategy: schema.NamingStrategy{ SingularTable: true, // 使用单数表名,启用该选项,此时,`User` 的表名应该是 `t_user` }, }) + if err != nil { + logx.Error("gorm初始化错误:", err.Error()) + return nil + } dockerClient, err := client.NewClientWithOpts() if err != nil { logx.Error(err.Error())