本文整理汇总了Golang中github.com/youtube/vitess/go/mysql.ConnectionParams.Pass方法的典型用法代码示例。如果您正苦于以下问题:Golang ConnectionParams.Pass方法的具体用法?Golang ConnectionParams.Pass怎么用?Golang ConnectionParams.Pass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/youtube/vitess/go/mysql.ConnectionParams
的用法示例。
在下文中一共展示了ConnectionParams.Pass方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: refreshPassword
// refreshPassword uses the CredentialServer to refresh the password
// to use.
func refreshPassword(params *mysql.ConnectionParams) error {
user, passwd, err := GetCredentialsServer().GetPassword(params.Uname)
switch err {
case nil:
params.Uname = user
params.Pass = passwd
case ErrUnknownUser:
default:
return err
}
return nil
}
示例2: createLookupClient
func createLookupClient(lookupConfigFile, dbCredFile string) (*DBClient, error) {
lookupConfigData, err := ioutil.ReadFile(lookupConfigFile)
if err != nil {
return nil, fmt.Errorf("Error %s in reading lookup-config-file %s", err, lookupConfigFile)
}
lookupClient := &DBClient{}
lookupConfig := new(mysql.ConnectionParams)
err = json.Unmarshal(lookupConfigData, lookupConfig)
if err != nil {
return nil, fmt.Errorf("error in unmarshaling lookupConfig data, err '%v'", err)
}
var lookupPasswd string
if dbCredFile != "" {
dbCredentials := make(map[string][]string)
dbCredData, err := ioutil.ReadFile(dbCredFile)
if err != nil {
return nil, fmt.Errorf("Error %s in reading db-credentials-file %s", err, dbCredFile)
}
err = json.Unmarshal(dbCredData, &dbCredentials)
if err != nil {
return nil, fmt.Errorf("Error in unmarshaling db-credentials-file %s", err)
}
if passwd, ok := dbCredentials[lookupConfig.Uname]; ok {
lookupPasswd = passwd[0]
}
}
lookupConfig.Pass = lookupPasswd
relog.Info("lookupConfig %v", lookupConfig)
lookupClient.dbConfig = lookupConfig
lookupClient.dbConn, err = lookupClient.Connect()
if err != nil {
return nil, fmt.Errorf("error in connecting to mysql db, err %v", err)
}
return lookupClient, nil
}