Description
Certain interfaces may have a mechanism to guarantee that a specific type is embedded.
For example, the <ServiceName>Server
interface generated by protoc-gen-go-grpc
contains an unexported mustEmbedUnimplemented<ServiceName>Server
method, which can be implemented by embedding the Unimplemented<ServiceName>Server
from the same package.
You can find more information here:
https://github.com/grpc/grpc-go/tree/master/cmd/protoc-gen-go-grpc#future-proofing-services
Real examples can be seen in the helloworld example of grpc-go:
- https://github.com/grpc/grpc-go/blob/941102b7811f/examples/helloworld/helloworld/helloworld_grpc.pb.go#L72-L76
- https://github.com/grpc/grpc-go/blob/941102b7811f/examples/helloworld/helloworld/helloworld_grpc.pb.go#L83-L88
To support this pattern, I propose a feature that allows specified types to be embedded in mocks. For instance, how about running moq -out mocks_test.go . MyInterface{Type1,Type2}
(or MyInterface:MyMock{Type1,Type2}
) to embed Type1 and Type2 in MyInterface mock?