Home > Article > Backend Development > Equality and Deep Equality
Why is there a difference between Equal and DeepEqual?
s1 := "abc" s2 := "abc" sv1 := reflect.ValueOf(s1) sv2 := reflect.ValueOf(s2) fmt.Println(sv1.Equal(sv2)) fmt.Println(reflect.DeepEqual(sv1, sv2))
The first prints true and the second prints false.
reflect.DeepEqual
seems to require some manual unboxing as it treats reflect.Value
s for struct
s instead of reflect.Value
s (reflect.DeepEqual(v1.Interface(), v2.Interface())">
The above is the detailed content of Equality and Deep Equality. For more information, please follow other related articles on the PHP Chinese website!