uber-go / mock

GoMock is a mocking framework for the Go programming language.
Apache License 2.0
2.13k stars 109 forks source link

Embed original interface into Mock struct #64

Open arxeiss opened 1 year ago

arxeiss commented 1 year ago

Requested feature

I would like to have option to embed original interface into generated Go structure.

Why the feature is needed

If the interface has unexported methods, the generated mock cannot be used as it does not fulfill the original interface. Embedding it however solves the issue. As discussed here https://groups.google.com/g/golang-nuts/c/6hpUErAfMHI

(Optional) Proposed solution

Solution should be pretty easy, as @stoikheia created PR in old repo https://github.com/golang/mock/pull/683

stoikheia commented 1 year ago

@arxeiss Thanks for open this issue with introducing my PR.

Your problem will be resolved if that suggestion is applied. I'll port it to this repo as a PR this week end.

ash2k commented 10 months ago

Just encountered this issue. Trying to generate mocks for OpenTelemetry interfaces and they have embedded interfaces with private methods. Sigh.

Example: https://github.com/open-telemetry/opentelemetry-go/blob/98b32a6c3a87fbee5d34c063b9096f416b250897/metric/asyncint64.go#L42-L49

lance6716 commented 6 months ago

@stoikheia kindly ping. Now I meet this problem. And I also ported your PR but need you to sign CLA