File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -752,8 +752,11 @@ func isEmpty(object interface{}) bool {
752752 return true
753753 }
754754
755- objValue := reflect .ValueOf (object )
755+ return isEmptyValue (reflect .ValueOf (object ))
756+ }
756757
758+ // isEmptyValue gets whether the specified reflect.Value is considered empty or not.
759+ func isEmptyValue (objValue reflect.Value ) bool {
757760 switch objValue .Kind () {
758761 // collection types are empty when they have no element
759762 case reflect .Chan , reflect .Map , reflect .Slice :
@@ -763,13 +766,12 @@ func isEmpty(object interface{}) bool {
763766 if objValue .IsNil () {
764767 return true
765768 }
766- deref := objValue .Elem ().Interface ()
767- return isEmpty (deref )
769+ return isEmptyValue (objValue .Elem ())
768770 // for all other types, compare against the zero value
769771 // array types are empty when they match their zero-initialized state
770772 default :
771773 zero := reflect .Zero (objValue .Type ())
772- return reflect .DeepEqual (object , zero .Interface ())
774+ return reflect .DeepEqual (objValue . Interface () , zero .Interface ())
773775 }
774776}
775777
You can’t perform that action at this time.
0 commit comments