mirror of
https://gitee.com/johng/gf.git
synced 2024-12-04 05:07:44 +08:00
非test文件 恢复 原样
This commit is contained in:
parent
d305d25935
commit
80cf3e833b
@ -204,14 +204,10 @@ func (j *Json) convertValue(value interface{}) interface{} {
|
||||
kind = rv.Kind()
|
||||
}
|
||||
switch kind {
|
||||
case reflect.Array:
|
||||
return gconv.Interfaces(value)
|
||||
case reflect.Slice:
|
||||
return gconv.Interfaces(value)
|
||||
case reflect.Map:
|
||||
return gconv.Map(value)
|
||||
case reflect.Struct:
|
||||
return gconv.Map(value)
|
||||
case reflect.Array: return gconv.Interfaces(value)
|
||||
case reflect.Slice: return gconv.Interfaces(value)
|
||||
case reflect.Map: return gconv.Map(value)
|
||||
case reflect.Struct: return gconv.Map(value)
|
||||
default:
|
||||
// Use json decode/encode at last.
|
||||
b, _ := Encode(value)
|
||||
@ -257,7 +253,6 @@ func (j *Json) getPointerByPattern(pattern string) *interface{} {
|
||||
|
||||
// Get a pointer to the value of specified <pattern> with violence check.
|
||||
func (j *Json) getPointerByPatternWithViolenceCheck(pattern string) *interface{} {
|
||||
//todo 此判断冗余
|
||||
if !j.vc {
|
||||
return j.getPointerByPatternWithoutViolenceCheck(pattern)
|
||||
}
|
||||
@ -297,7 +292,6 @@ func (j *Json) getPointerByPatternWithViolenceCheck(pattern string) *interface{}
|
||||
|
||||
// Get a pointer to the value of specified <pattern>, with no violence check.
|
||||
func (j *Json) getPointerByPatternWithoutViolenceCheck(pattern string) *interface{} {
|
||||
//todo 此判断冗余
|
||||
if j.vc {
|
||||
return j.getPointerByPatternWithViolenceCheck(pattern)
|
||||
}
|
||||
|
@ -48,8 +48,7 @@ func New(data interface{}, unsafe ...bool) *Json {
|
||||
kind = rv.Kind()
|
||||
}
|
||||
switch kind {
|
||||
case reflect.Slice:
|
||||
fallthrough
|
||||
case reflect.Slice: fallthrough
|
||||
case reflect.Array:
|
||||
i := interface{}(nil)
|
||||
i = gconv.Interfaces(data)
|
||||
@ -58,8 +57,7 @@ func New(data interface{}, unsafe ...bool) *Json {
|
||||
c : byte(gDEFAULT_SPLIT_CHAR),
|
||||
vc : false ,
|
||||
}
|
||||
case reflect.Map:
|
||||
fallthrough
|
||||
case reflect.Map: fallthrough
|
||||
case reflect.Struct:
|
||||
i := interface{}(nil)
|
||||
i = gconv.Map(data, "json")
|
||||
@ -169,7 +167,7 @@ func LoadContent(data interface{}, unsafe ...bool) (*Json, error) {
|
||||
case "toml", ".toml":
|
||||
// TODO UseNumber
|
||||
b, err = gtoml.ToJson(b)
|
||||
//todo 不可达
|
||||
|
||||
default:
|
||||
err = errors.New("nonsupport type " + t)
|
||||
}
|
||||
|
@ -251,7 +251,6 @@ func (c *Config) GetFileName() string {
|
||||
// If any error occurs, it return nil.
|
||||
func (c *Config) getJson(file...string) *gjson.Json {
|
||||
name := c.name.Val()
|
||||
//todo 此函数file参数无效,没有地方调用,且有SetFileName函数提供链式操作,因此建议去掉
|
||||
if len(file) > 0 {
|
||||
name = file[0]
|
||||
}
|
||||
@ -381,6 +380,7 @@ func (c *Config) GetInt(pattern string, def ...interface{}) int {
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
func (c *Config) GetInt8(pattern string, def...interface{}) int8 {
|
||||
if j := c.getJson(); j != nil {
|
||||
return j.GetInt8(pattern, def...)
|
||||
@ -489,3 +489,4 @@ func (c *Config) Reload() {
|
||||
func (c *Config) Clear() {
|
||||
c.jsons.Clear()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user