Files
jx-print/globals/globals.go
2021-07-06 11:36:58 +08:00

23 lines
454 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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=LocalMySQL的时区设置
sqlStr := "root:123456@tcp(127.0.0.1:3306)/testdb?charset=utf8&parseTime=true&loc=Local"
db, _ = sql.Open("mysql", sqlStr)
}