From 435a03dd34ffd3c43f44f4cc00ab3a88457250d7 Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Fri, 16 Dec 2022 16:55:28 +0800 Subject: [PATCH] fix: nil reference while trying to shut down DB in slave mode (#1416) --- main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index d309b8f..acb155a 100644 --- a/main.go +++ b/main.go @@ -42,7 +42,11 @@ func init() { func main() { // 关闭数据库连接 - defer model.DB.Close() + defer func() { + if model.DB != nil { + model.DB.Close() + } + }() if isEject { // 开始导出内置静态资源文件