mirror of
https://github.com/golang/go
synced 2024-11-16 22:54:47 -07:00
encoding/json: use reflect.Value.IsZero
IsZero does the same thing, using this rather than writing it again.
This commit is contained in:
parent
14c347f5ce
commit
dfbc6ed635
@ -307,16 +307,12 @@ func isEmptyValue(v reflect.Value) bool {
|
|||||||
switch v.Kind() {
|
switch v.Kind() {
|
||||||
case reflect.Array, reflect.Map, reflect.Slice, reflect.String:
|
case reflect.Array, reflect.Map, reflect.Slice, reflect.String:
|
||||||
return v.Len() == 0
|
return v.Len() == 0
|
||||||
case reflect.Bool:
|
case reflect.Bool,
|
||||||
return v.Bool() == false
|
reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,
|
||||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr,
|
||||||
return v.Int() == 0
|
reflect.Float32, reflect.Float64,
|
||||||
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
|
reflect.Interface, reflect.Pointer:
|
||||||
return v.Uint() == 0
|
return v.IsZero()
|
||||||
case reflect.Float32, reflect.Float64:
|
|
||||||
return v.Float() == 0
|
|
||||||
case reflect.Interface, reflect.Pointer:
|
|
||||||
return v.IsNil()
|
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user