本文整理匯總了Golang中github.com/c4pt0r/cfg.Cfg.ReadString方法的典型用法代碼示例。如果您正苦於以下問題:Golang Cfg.ReadString方法的具體用法?Golang Cfg.ReadString怎麽用?Golang Cfg.ReadString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/c4pt0r/cfg.Cfg
的用法示例。
在下文中一共展示了Cfg.ReadString方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: LoadCodisEnv
func LoadCodisEnv(cfg *cfg.Cfg) Env {
if cfg == nil {
log.Panicf("config is nil")
}
productName, err := cfg.ReadString("product", "test")
if err != nil {
log.PanicErrorf(err, "read product name failed")
}
zkAddr, err := cfg.ReadString("zk", "localhost:2181")
if err != nil {
log.PanicErrorf(err, "read zk address failed")
}
hostname, _ := os.Hostname()
dashboardAddr, err := cfg.ReadString("dashboard_addr", hostname+":18087")
if err != nil {
log.PanicErrorf(err, "read dashboard address failed")
}
provider, err := cfg.ReadString("coordinator", "zookeeper")
if err != nil {
log.PanicErrorf(err, "read coordinator failed")
}
return &CodisEnv{
zkAddr: zkAddr,
dashboardAddr: dashboardAddr,
productName: productName,
provider: provider,
}
}
示例2: LoadCodisEnv
func LoadCodisEnv(cfg *cfg.Cfg) Env {
if cfg == nil {
log.Fatal("config error")
}
productName, err := cfg.ReadString("product", "test")
if err != nil {
log.Fatal(err)
}
zkAddr, err := cfg.ReadString("zk", "localhost:2181")
if err != nil {
log.Fatal(err)
}
hostname, _ := os.Hostname()
dashboardAddr, err := cfg.ReadString("dashboard_addr", hostname+":18087")
if err != nil {
log.Fatal(err)
}
provider, err := cfg.ReadString("coordinator", "zookeeper")
if err != nil {
log.Fatal(err)
}
return &CodisEnv{
zkAddr: zkAddr,
dashboardAddr: dashboardAddr,
productName: productName,
provider: provider,
}
}
示例3: LoadRebornEnv
func LoadRebornEnv(cfg *cfg.Cfg) Env {
if cfg == nil {
log.Fatal("unexpected empty config")
}
productName, err := cfg.ReadString("product", "test")
if err != nil {
log.Fatal(err)
}
coordinatorAddr, err := cfg.ReadString("coordinator_addr", "localhost:2181")
if err != nil {
log.Fatal(err)
}
hostname, err := os.Hostname()
if err != nil {
log.Fatal(err)
}
dashboardAddr, err := cfg.ReadString("dashboard_addr", hostname+":18087")
if err != nil {
log.Fatal(err)
}
coordinator, err := cfg.ReadString("coordinator", "zookeeper")
if err != nil {
log.Fatal(err)
}
storeAuth, _ := cfg.ReadString("store_auth", "")
return &RebornEnv{
dashboardAddr: dashboardAddr,
productName: productName,
coordinator: coordinator,
coordinatorAddr: coordinatorAddr,
storeAuth: storeAuth,
}
}
示例4: LoadCodisEnv
func LoadCodisEnv(cfg *cfg.Cfg) Env {
if cfg == nil {
log.Panicf("config is nil")
}
productName, err := cfg.ReadString("product", "test")
if err != nil {
log.PanicErrorf(err, "config: 'product' not found")
}
zkAddr, err := cfg.ReadString("zk", "localhost:2181")
if err != nil {
log.PanicErrorf(err, "config: 'zk' not found")
}
hostname, _ := os.Hostname()
dashboardAddr, err := cfg.ReadString("dashboard_addr", hostname+":18087")
if err != nil {
log.PanicErrorf(err, "config: 'dashboard_addr' not found")
}
provider, err := cfg.ReadString("coordinator", "zookeeper")
if err != nil {
log.PanicErrorf(err, "config: 'coordinator' not found")
}
passwd, _ := cfg.ReadString("password", "")
return &CodisEnv{
zkAddr: zkAddr,
passwd: passwd,
dashboardAddr: dashboardAddr,
productName: productName,
provider: provider,
}
}