本文整理匯總了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
}