本文整理汇总了Golang中github.com/c4pt0r/cfg.Cfg类的典型用法代码示例。如果您正苦于以下问题:Golang Cfg类的具体用法?Golang Cfg怎么用?Golang Cfg使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Cfg类的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,
}
}