mock icon indicating copy to clipboard operation
mock copied to clipboard

Embed original interface into Mock struct

Open arxeiss opened this issue 2 years ago • 4 comments

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

arxeiss avatar Aug 17 '23 07:08 arxeiss

@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.

stoikheia avatar Aug 28 '23 14:08 stoikheia

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

ash2k avatar Nov 29 '23 07:11 ash2k

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

lance6716 avatar Mar 28 '24 08:03 lance6716

Can a reviewer please take a look at this: https://github.com/uber-go/mock/pull/171

nikzadkhani avatar May 02 '25 19:05 nikzadkhani