Looking at the following golang code:
b := []byte(`["a", "b"]`)
var value interface{}
json.Unmarshal(b, &value)
fmt.Println(value) // Print [a b]
fmt.Println(reflect.TypeOf(value)) //Print []interface {}
var targetValue interface{} = []string{"a", "b"}
if reflect.DeepEqual(value.([]interface{}), targetValue) {
t.Error("please be equal")
}
Am I expecting too much of DeepEqual
? Reading the documentation, the following statements reinforce my assumption that it should work:
- Array values are deeply equal when their corresponding elements are deeply equal.
- Interface values are deeply equal if they hold deeply equal concrete values.
- Slice values are deeply equal when (...) or their corresponding elements (up to length) are deeply equal.
What am I missing here?