You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.
Requested feature
Optional -interfaces flag for source mode so it will be possible to list only those interfaces that needed to be mocked.
Why the feature is needed
Using reflect mode it is possible to list only required interfaces. For example, if there is a file with 3 different interfaces and the developer wants to generate mocks only for 2 of them it is not possible with go:generate annotation:
Such an approach won't work cause there will be two generated files in the same package with the same content which includes all 3 interfaces. There also will be conflicts between these two files.
The example above won't work also, there will be all 3 interface mocks in the generated file. (Optional) Proposed solution
Introduce flag -interfaces which accepts a list of required interfaces separated by a comma. It will work like this:
As a result, 2 files will be generated each containing a separate interface, Foo in foo_mock.go and Bar in bar_mock.go respectively.
Also if we need Foo and Bar in a single generated file that will work also like this:
Thanks for the request I will take a look at the PR shortly. Overall I think this is a good idea but could be tricky too with things like nested interfaces.
@codyoss Hey! Did you have a chance to check the PR? I tested it with nested interfaces, seems like it is working as expected. Or could you specify the case, please?
Requested feature
Optional -interfaces flag for source mode so it will be possible to list only those interfaces that needed to be mocked.
Why the feature is needed
Using reflect mode it is possible to list only required interfaces. For example, if there is a file with 3 different interfaces and the developer wants to generate mocks only for 2 of them it is not possible with
go:generate
annotation:Such an approach won't work cause there will be two generated files in the same package with the same content which includes all 3 interfaces. There also will be conflicts between these two files.
The example above won't work also, there will be all 3 interface mocks in the generated file.
(Optional) Proposed solution
Introduce flag
-interfaces
which accepts a list of required interfaces separated by a comma. It will work like this:As a result, 2 files will be generated each containing a separate interface, Foo in foo_mock.go and Bar in bar_mock.go respectively.
Also if we need Foo and Bar in a single generated file that will work also like this:
The text was updated successfully, but these errors were encountered: