From 2279a03fe830e7a63c9f6eb8adc7ce4a116d07f4 Mon Sep 17 00:00:00 2001 From: zhangwei <894646498@qq.com> Date: Tue, 12 Dec 2023 18:09:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Former-commit-id: 1a63fdb8a0d001c5e619494c197b1d9f67fafd47 --- api/internal/svc/servicecontext.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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())