vendor: github.com/hashicorp/go-msgpack v0.5.5 (indirect)

updating to the latest v0.5.x patch release:

full diff: https://github.com/hashicorp/go-msgpack/compare/v0.5.3...v0.5.5

- Fix an issue where struct pointer fields tagged with omitempty will be omitted
  if referenced value is empty, so a field of type *bool, then field would be
  omitted pointer is nil or &false.
- Fixed a decoding issue when decoding a string value in a map where the value
  already existed would panic.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-06-29 15:59:00 +02:00
parent 4e87a758f6
commit 421b93dcf5
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
6 changed files with 21 additions and 8 deletions

View File

@ -120,7 +120,7 @@ require (
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-msgpack v0.5.3 // indirect
github.com/hashicorp/go-msgpack v0.5.5 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-sockaddr v1.0.2 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect

View File

@ -614,8 +614,9 @@ github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJ
github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
github.com/hashicorp/go-memdb v1.3.2 h1:RBKHOsnSszpU6vxq80LzC2BaQjuuvoyaQbkLTf7V7g8=
github.com/hashicorp/go-memdb v1.3.2/go.mod h1:Mluclgwib3R93Hk5fxEfiRhB+6Dar64wWh71LpNSe3g=
github.com/hashicorp/go-msgpack v0.5.3 h1:zKjpN5BK/P5lMYrLmBHdBULWbJ0XpYR+7NGzqkZzoD4=
github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
github.com/hashicorp/go-msgpack v0.5.5 h1:i9R9JSrqIz0QVLz3sz+i3YJdT7TTSLcfLLzJi9aZTuI=
github.com/hashicorp/go-msgpack v0.5.5/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
github.com/hashicorp/go-multierror v0.0.0-20161216184304-ed905158d874/go.mod h1:JMRHfdO9jKNzS/+BTlxCjKNQHg/jZAft8U7LloJvN7I=
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=

View File

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

View File

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

View File

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

2
vendor/modules.txt vendored
View File

@ -417,7 +417,7 @@ github.com/hashicorp/go-immutable-radix
# github.com/hashicorp/go-memdb v1.3.2
## explicit; go 1.12
github.com/hashicorp/go-memdb
# github.com/hashicorp/go-msgpack v0.5.3
# github.com/hashicorp/go-msgpack v0.5.5
## explicit
github.com/hashicorp/go-msgpack/codec
# github.com/hashicorp/go-multierror v1.1.1