本文整理汇总了Golang中github.com/dlintw/goconf.ConfigFile.GetBool方法的典型用法代码示例。如果您正苦于以下问题:Golang ConfigFile.GetBool方法的具体用法?Golang ConfigFile.GetBool怎么用?Golang ConfigFile.GetBool使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/dlintw/goconf.ConfigFile
的用法示例。
在下文中一共展示了ConfigFile.GetBool方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: parseRESTConfig
func parseRESTConfig(conf *goconf.ConfigFile) (*restConfig, error) {
var err error
c := &restConfig{}
c.tls.enable, err = conf.GetBool("rest", "tls")
if err != nil {
return nil, errors.New("invalid rest/tls value")
}
port, err := conf.GetInt("rest", "port")
if err != nil || port <= 0 || port > 65535 {
return nil, errors.New("empty or invalid rest/port value")
}
c.port = uint16(port)
c.tls.certFile, err = conf.GetString("rest", "cert_file")
if err != nil || len(c.tls.certFile) == 0 {
return nil, errors.New("empty rest/cert_file value")
}
if c.tls.certFile[0] != '/' {
return nil, errors.New("rest/cert_file should be specified as an absolute path")
}
c.tls.keyFile, err = conf.GetString("rest", "key_file")
if err != nil || len(c.tls.keyFile) == 0 {
return nil, errors.New("empty rest/key_file value")
}
if c.tls.keyFile[0] != '/' {
return nil, errors.New("rest/key_file should be specified as an absolute path")
}
return c, nil
}
示例2: GlobalTls
// Sets global variable to enable TLS communications and other related variables (certificate path, organization)
// optional parameters: default.certpath, default.organization, default.tls
func GlobalTls(configFile *goconf.ConfigFile) {
certificatepath, err := configFile.GetString("default", "certpath")
if err != nil {
logger.Warn(err)
} else {
certpath = certificatepath
}
logger.Printf("certpath=[%v]", certpath)
certificateorg, err := configFile.GetString("default", "organization")
if err != nil {
logger.Warn(err)
if certificateorg, err = os.Hostname(); err != nil {
logger.Warn(err)
certificateorg = "golem.googlecode.com"
}
}
certorg = certificateorg
logger.Printf("certorg=[%v]", certorg)
useTlsl, err := configFile.GetBool("default", "tls")
if err != nil {
logger.Warn(err)
useTls = true
} else {
useTls = useTlsl
}
logger.Printf("TLS=[%v]", useTls)
}
示例3: GlobalLogger
// sets global logger based on verbosity level in configuration
// optional parameter: default.verbose (defaults to true if not present or incorrectly set)
func GlobalLogger(configFile *goconf.ConfigFile) {
verbose, err := configFile.GetBool("default", "verbose")
logger = log4go.NewVerboseLogger(verbose, nil, "")
if err != nil {
logger.Warn(err)
verbose = true
}
logger.Printf("verbose set [%v]", verbose)
}
示例4: MongoLogger
func MongoLogger(configFile *goconf.ConfigFile) {
verbose, err := configFile.GetBool("mgodb", "verbose")
if err != nil {
logger.Warn(err)
verbose = false
}
logger.Printf("mongo logger verbose set [%v]", verbose)
if verbose {
mgo.SetLogger(logger)
mgo.SetDebug(verbose)
}
}