1
0
mirror of https://github.com/astaxie/beego.git synced 2024-12-22 18:40:49 +00:00

修复数据库连接异常问题

This commit is contained in:
leapsea 2020-05-09 16:31:30 +08:00
parent 8f3d1c5f42
commit 867f83de34

View File

@ -374,6 +374,7 @@ func SetMaxIdleConns(aliasName string, maxIdleConns int) {
func SetMaxOpenConns(aliasName string, maxOpenConns int) {
al := getDbAlias(aliasName)
al.MaxOpenConns = maxOpenConns
al.DB.DB.SetMaxOpenConns(maxOpenConns)
// for tip go 1.2
if fun := reflect.ValueOf(al.DB).MethodByName("SetMaxOpenConns"); fun.IsValid() {
fun.Call([]reflect.Value{reflect.ValueOf(maxOpenConns)})