非test文件 恢复 原样

This commit is contained in:
piaohao 2019-06-13 12:41:20 +08:00
parent d305d25935
commit 80cf3e833b
3 changed files with 708 additions and 715 deletions

View File

@ -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)
}

View File

@ -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)
}

View File

@ -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()
}