-
-
Notifications
You must be signed in to change notification settings - Fork 669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Circular dependencies when including mocks generated by gomock
in go_library
#3349
Comments
gomock
in go_library
gomock
in go_library
@linzhp I have also wondered about why |
Yeah. It was designed that way so the reflective mode and source mode can share the same argument. |
I think this is a change from when gomock was a separate project. When I moved to using the contrib one, I've had to add a |
What version of rules_go are you using?
0.34.0
What version of gazelle are you using?
0.26.0
What version of Bazel are you using?
5.1.1
Does this issue reproduce with the latest releases of all the above?
Yes
What operating system and processor architecture are you using?
MacOS x86_64
Any other potentially useful information about your toolchain?
N/A
What did you do?
I'm attempting to generate mocks using
gomock
and include those mocks as part of ago_library
, such that other packages within my codebase can consume those mocks as part of their test cases. I'm using thesource
mode forgomock
, which should only require passing in a single file to generate mocks from as opposed to a full library. Simplest reproducible case:With BUILD file:
What did you expect to see?
Build should pass.
What did you see instead?
A circular dependency occurs:
I've had a look through the source code and can see that the only reason a
go_library
is required is for it'simportpath
:https://github.com/bazelbuild/rules_go/blob/2113d18ca1817e8529d7fa44e40af2742f6b2633/extras/gomock.bzl#L38
Patching the rule to allow passing an
importpath
directly bypasses this isssue, and also seems more in line with how source mode is intended to be used. This looks like the following:The text was updated successfully, but these errors were encountered: