本文整理匯總了Golang中github.com/magiconair/properties.Properties.GetString方法的典型用法代碼示例。如果您正苦於以下問題:Golang Properties.GetString方法的具體用法?Golang Properties.GetString怎麽用?Golang Properties.GetString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/magiconair/properties.Properties
的用法示例。
在下文中一共展示了Properties.GetString方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: FromProperties
func FromProperties(p *properties.Properties) (*Config, error) {
var cfg *Config = &Config{}
cfg.Listen.Port = p.GetString("receiver.addr", DefaultConfig.Listen.Port)
return cfg, nil
}
示例2: buildURI
//"mongodb://linker:[email protected]:27017,172.17.2.44:27017/linker"
func buildURI(config *properties.Properties) string {
uri := config.GetString("uri", "")
if len(uri) <= 0 {
return uri
}
var commandTextBuffer bytes.Buffer
username := config.GetString("username", "")
password := config.GetString("password", "")
// port := config.GetString("port", "27017")
database := config.GetString("database", "")
prefix := "mongodb://"
commandTextBuffer.WriteString(prefix)
commandTextBuffer.WriteString(username + ":")
commandTextBuffer.WriteString(password + "@")
rs := []rune(uri)
ipPart := string(rs[len(prefix):len(uri)])
ips := strings.Split(ipPart, ",")
lenth := len(ips)
for i := 0; i < lenth-1; i++ {
ip := ips[i] + ","
commandTextBuffer.WriteString(ip)
}
lastIP := ips[lenth-1] + "/" + database
commandTextBuffer.WriteString(lastIP)
return commandTextBuffer.String()
}