proposal: errors: make different results from New not reflect.DeepEqual #15910
Labels
FrozenDueToAge
NeedsDecision
Feedback is required from experts, contributors, and/or the community before a change can be made.
Proposal
v2
A language change or incompatible library change
Milestone
Currently, in
go1.6
, differenterror
values returned byerrors.New(...)
are equal (in the sense of the reflect.DeepEqual usage) if they have the same error message. This encourages people to write unit tests like the following:This is a poor test it assumes an exact error message and type for an unexported error from a given package. Instead, we should cause DeepEqual to always return false somehow by embedding some field in the concrete
errorString
type that always compares to false for anything but itself.Thus, I expect the following to happen:
We probably cannot change this in Go1 because the sheer number of tests this would probably break, but it may be worth considering for Go2.
The text was updated successfully, but these errors were encountered: