diff --git a/mapstructure.go b/mapstructure.go index 1f646317..d7ed4473 100644 --- a/mapstructure.go +++ b/mapstructure.go @@ -1163,7 +1163,7 @@ func (d *Decoder) decodeArray(name string, data interface{}, val reflect.Value) valArray := val - if valArray.Comparable() && valArray.Interface() == reflect.Zero(valArray.Type()).Interface() || d.config.ZeroFields { + if isComparable(valArray) && valArray.Interface() == reflect.Zero(valArray.Type()).Interface() || d.config.ZeroFields { // Check input type if dataValKind != reflect.Array && dataValKind != reflect.Slice { if d.config.WeaklyTypedInput { diff --git a/reflect.go b/reflect.go new file mode 100644 index 00000000..d3174f9f --- /dev/null +++ b/reflect.go @@ -0,0 +1,7 @@ +package mapstructure + +import "reflect" + +func isComparable(v reflect.Value) bool { + return v.Comparable() +} diff --git a/reflect_go1_19.go b/reflect_go1_19.go new file mode 100644 index 00000000..6b8c71ae --- /dev/null +++ b/reflect_go1_19.go @@ -0,0 +1,9 @@ +//go:build !go1.20 + +package mapstructure + +import "reflect" + +func isComparable(v reflect.Value) bool { + return true +}