0 Star 0 Fork 0

ChengLucas / goconf

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
format.go 922 Bytes
Copy Edit Raw Blame History
chengyunlai authored 2016-05-06 09:31 . init
package goconf
import (
"strconv"
)
func (cfg Configuration) Sub(key string) Configuration {
temp := cfg.Get(key)
if nil != temp {
if ret, isOk := temp.(Configuration); isOk {
return ret
}
}
return nil
}
func (cfg Configuration) String(key string) string {
temp := cfg.Get(key)
if nil != temp {
if ret, isOk := temp.(string); isOk {
return ret
}
}
return ""
}
func (cfg Configuration) Integer(key string) int {
if ret, e := strconv.Atoi(cfg.String(key)); nil == e {
return ret
}
return 0
}
// It accepts 1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False.
// Any other value returns false.
func (cfg Configuration) Bool(key string) bool {
if ret, e := strconv.ParseBool(cfg.String(key)); nil == e {
return ret
}
return false
}
func (cfg Configuration) Float64(key string) float64 {
if ret, e := strconv.ParseFloat(cfg.String(key), 64); nil == e {
return ret
}
return 0.0
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/plus1/goconf.git
git@gitee.com:plus1/goconf.git
plus1
goconf
goconf
master

Search

344bd9b3 5694891 D2dac590 5694891