Open
Description
This code doesn't do what you think it does:
func f(x, y reflect.Value) bool {
return reflect.DeepEqual(x, y)
}
It compares the internal details of the two reflect.Value
structs, not their contents. The correct code would be reflect.DeepEqual(x.Interface(), y.Interface())
.
I don't see any reason why you'd ever want to use DeepEqual
on a reflect.Value
. Hence no false positives.
If you really wanted to compare two reflect.Value
s (but you shouldn't), ==
is equivalent to DeepEqual
.
Seems like an easy mistake to make (see #43986 ). Not sure how common it might be, but I suspect it might be common enough to warrant a check.
Metadata
Metadata
Assignees
Type
Projects
Status
Accepted