From de7ca15b3d81f8d983ebf885ed7d33976b4c4b3d Mon Sep 17 00:00:00 2001 From: suyl <770236076@qq.com> Date: Tue, 6 Jul 2021 11:36:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E8=BF=9E=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- globals/globals.go | 11 ++++++++++- model/user.go | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 model/user.go diff --git a/globals/globals.go b/globals/globals.go index 7450f0b..5126fb4 100644 --- a/globals/globals.go +++ b/globals/globals.go @@ -1,14 +1,23 @@ package globals import ( + "database/sql" "go.uber.org/zap" ) var ( SugarLogger *zap.SugaredLogger -) + db *sql.DB + ) func init() { logger, _ := zap.NewDevelopment() SugarLogger = logger.Sugar() + + //parseTime:时间格式转换(查询结果为时间时,是否自动解析为时间); + + // loc=Local:MySQL的时区设置 + + sqlStr := "root:123456@tcp(127.0.0.1:3306)/testdb?charset=utf8&parseTime=true&loc=Local" + db, _ = sql.Open("mysql", sqlStr) } \ No newline at end of file diff --git a/model/user.go b/model/user.go new file mode 100644 index 0000000..868de98 --- /dev/null +++ b/model/user.go @@ -0,0 +1,2 @@ +package model +