From 3f4aa9f7d4d02b15c760c0600a0be805682cc987 Mon Sep 17 00:00:00 2001 From: dustoair <107600816+dustoair@users.noreply.github.com> Date: Thu, 28 Jul 2022 19:14:12 +0800 Subject: [PATCH] defer global.DB.Close() --- main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index b1c74e5..cbea40a 100644 --- a/main.go +++ b/main.go @@ -103,7 +103,7 @@ func init() { third_part.GetRemoteToken() //初始化数据库 global.DB = InitDB() - defer global.DB.Close() + log.Println("数据库初始化成功") log.Println("server init success") @@ -123,4 +123,5 @@ func main() { } log.Println("server start at port:", port) log.Fatalln(http.ListenAndServe(":"+port, nil)) + defer global.DB.Close() }