-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed as not planned
Closed as not planned
Copy link
Labels
LibraryProposalIssues describing a requested change to the Go standard library or x/ libraries, but not to a toolIssues describing a requested change to the Go standard library or x/ libraries, but not to a toolProposal
Milestone
Description
Proposal Details
Currently, reflect.DeepEqual
considers all non-nil functions as un-equal, even if they are the same function:
Lines 154 to 159 in 1a93e4a
case Func: | |
if v1.IsNil() && v2.IsNil() { | |
return true | |
} | |
// Can't do better than this: | |
return false |
reflect.DeepEqual
should be extended to consider identical functions as equal:
case Func:
return v1.Pointer() == v2.Pointer()
This would allow users to assert that one struct "is" another struct:
func TestRoundTrip(x T) {
if !reflect.DeepEqual(x, blackBox(x)) {
panic("not equal")
}
}
That identical functions are not equal is surprising.
Metadata
Metadata
Assignees
Labels
LibraryProposalIssues describing a requested change to the Go standard library or x/ libraries, but not to a toolIssues describing a requested change to the Go standard library or x/ libraries, but not to a toolProposal