Этот коммит содержится в:
Christopher Speller
2019-07-29 07:39:56 -07:00
коммит произвёл GitHub
родитель f226f672f3
Коммит 20825a1702
547 изменённых файлов: 44126 добавлений и 27501 удалений

2
vendor/github.com/hashicorp/go-msgpack/codec/decode.go сгенерированный поставляемый
Просмотреть файл

@@ -527,7 +527,7 @@ func (f *decFnInfo) kMap(rv reflect.Value) {
}
}
rvv := rv.MapIndex(rvk)
if !rvv.IsValid() {
if !rvv.IsValid() || !rvv.CanSet() {
rvv = reflect.New(vtype).Elem()
}

7
vendor/github.com/hashicorp/go-msgpack/codec/helper.go сгенерированный поставляемый
Просмотреть файл

@@ -45,6 +45,13 @@ const (
// for debugging, set this to false, to catch panic traces.
// Note that this will always cause rpc tests to fail, since they need io.EOF sent via panic.
recoverPanicToErr = true
// if checkStructForEmptyValue, check structs fields to see if an empty value.
// This could be an expensive call, so possibly disable it.
checkStructForEmptyValue = false
// if derefForIsEmptyValue, deref pointers and interfaces when checking isEmptyValue
derefForIsEmptyValue = false
)
type charEncoding uint8

13
vendor/github.com/hashicorp/go-msgpack/codec/helper_internal.go сгенерированный поставляемый
Просмотреть файл

@@ -33,8 +33,10 @@ func panicValToErr(panicVal interface{}, err *error) {
return
}
func isEmptyValueDeref(v reflect.Value, deref bool) bool {
func hIsEmptyValue(v reflect.Value, deref, checkStruct bool) bool {
switch v.Kind() {
case reflect.Invalid:
return true
case reflect.Array, reflect.Map, reflect.Slice, reflect.String:
return v.Len() == 0
case reflect.Bool:
@@ -50,18 +52,21 @@ func isEmptyValueDeref(v reflect.Value, deref bool) bool {
if v.IsNil() {
return true
}
return isEmptyValueDeref(v.Elem(), deref)
return hIsEmptyValue(v.Elem(), deref, checkStruct)
} else {
return v.IsNil()
}
case reflect.Struct:
if !checkStruct {
return false
}
// return true if all fields are empty. else return false.
// we cannot use equality check, because some fields may be maps/slices/etc
// and consequently the structs are not comparable.
// return v.Interface() == reflect.Zero(v.Type()).Interface()
for i, n := 0, v.NumField(); i < n; i++ {
if !isEmptyValueDeref(v.Field(i), deref) {
if !hIsEmptyValue(v.Field(i), deref, checkStruct) {
return false
}
}
@@ -71,7 +76,7 @@ func isEmptyValueDeref(v reflect.Value, deref bool) bool {
}
func isEmptyValue(v reflect.Value) bool {
return isEmptyValueDeref(v, true)
return hIsEmptyValue(v, derefForIsEmptyValue, checkStructForEmptyValue)
}
func debugf(format string, args ...interface{}) {