代码拉取完成,页面将自动刷新
package database
import (
"gitee.com/zhucheer/orange/cfg"
"github.com/zhuCheer/pool"
"regexp"
"strings"
)
type DataBase interface {
RegisterAll()
Register(string)
insertPool(string, pool.Pool)
getDB(string) (interface{}, func(), error)
putDB(string, interface{}) error
}
// RegisterAll 注册所有支持的驱动
func RegisterAll() {
go NewMysql().RegisterAll()
go NewGorm().RegisterAll()
go NewRedis().RegisterAll()
go NewMongo().RegisterAll()
go NewPostgre().RegisterAll()
}
// PutConn 将连接放回连接池方法
func PutConn(put func()) {
if put == nil {
return
}
put()
return
}
func getDBIntConfig(dbtype, name, key string) int {
exists := cfg.Config.Exists("database." + dbtype + "." + name + "." + key)
if exists == false {
return cfg.Config.GetInt("database." + key)
}
return cfg.Config.GetInt("database." + dbtype + "." + name + "." + key)
}
func getBoolConfig(dbtype, name, key string) bool {
exists := cfg.Config.Exists("database." + dbtype + "." + name + "." + key)
if exists == false {
return cfg.Config.GetBool("database." + key)
}
return cfg.Config.GetBool("database." + dbtype + "." + name + "." + key)
}
// 隐藏连接密码日志
func hideDsnPasswordLog(dsn string) (hideDsn string) {
hideDsn = dsn
hideDsnData := regexp.MustCompile(`\/\/[\w]+\:(.*)@`).FindStringSubmatch(dsn)
if len(hideDsnData) > 1 {
hideDsn = strings.Replace(dsn, hideDsnData[1], "******", -1)
}
return
}
func hideTcpDsnPasswordLog(dsn string) (hideDsn string) {
hideDsn = dsn
hideDsnData := regexp.MustCompile(`[\w]+\:(.*)@tcp`).FindStringSubmatch(dsn)
if len(hideDsnData) > 1 {
hideDsn = strings.Replace(dsn, hideDsnData[1], "******", -1)
}
return
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。