Closed elb3k closed 11 months ago
I believe gomock's default matcher should not take on technology specific dependencies outside of go's standard ecosystem.
If proto specific logic is added, there's an argument that thrift specific logic should be added and so on and so forth which increases the maintenance burden of this library. Looking at this change, a custom matcher for this use case seems sufficient.
Wont fix. We can continue to discuss this in an issue or a Discussion but any change for gomock's default matchers should be proto agnostic.
Sample code for a custom proto matcher.
type protoMatcher struct{ msg proto.Message }
var _ gomock.Matcher = (*protoMatcher)(nil)
func (m *protoMatcher) String() string { / *... TODO .. */ }
func (m *protoMatcher) Matches(x any) bool {
other, ok := x.(proto.Message)
if !ok { return false }
return proto.Equal(m.msg, other)
}
Gomock is used with GRPC services. And sometimes there is an error when matching the proto messages. Using
proto.Equal
if the arguments are proto messages will be helpful.