Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql Gorm Ping Db碎片_Sql_Go_Go Gorm - Fatal编程技术网

Sql Gorm Ping Db碎片

Sql Gorm Ping Db碎片,sql,go,go-gorm,Sql,Go,Go Gorm,我希望在我的应用程序中管理DB碎片的映射。使用GORM时,主动PING所有碎片以验证连接的过程是什么 我正在寻找类似于: import ( "github.com.jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/mysql" ) for _, shard := range shardMap { if err := shard.Ping() { //DO SOMETHING } } 问题是shard.Ping

我希望在我的应用程序中管理DB碎片的映射。使用GORM时,主动PING所有碎片以验证连接的过程是什么

我正在寻找类似于:

import (
   "github.com.jinzhu/gorm"
   _ "github.com/jinzhu/gorm/dialects/mysql"

)

for _, shard := range shardMap {
   if err := shard.Ping() {
      //DO SOMETHING
   }
}

问题是shard.Ping()不是一件事。我觉得我错过了一个重要的地方

作为后续操作,其语法如下

shard.DB().Ping()