當前位置: 首頁>>代碼示例>>Golang>>正文


Golang ConnectionParams.Pass方法代碼示例

本文整理匯總了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
}
開發者ID:nimishzynga,項目名稱:vitess,代碼行數:14,代碼來源:dbconfigs.go

示例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
}
開發者ID:shrutip,項目名稱:vitess,代碼行數:39,代碼來源:vt_binlog_player.go


注:本文中的github.com/youtube/vitess/go/mysql.ConnectionParams.Pass方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。