-
Notifications
You must be signed in to change notification settings - Fork 29
Mock system packages #10
Comments
I have a workaround for you and have opened a ticket with the rules_go folks to make a nicer solution. It looks like there's no bazel targets for individual packages in the stdlib provided by rules_go (in the What we can do is use a type alias and use gomock in reflect mode (not source mode because source mode can't import packages). So, you'd add something like
to a source file under your control. Then you'd set it up the reflect mode gomock as something like:
The important bits are that the You don't have to actually use your local I'm going to leave this open til we figure out if there's a better solution in bazel-contrib/rules_go#1944 |
(I'm pretty sure that you don't have to export that type alias, too, if the alias is in the same package as the generated and test code but haven't checked it.) |
(Typoed the |
Great, thanks! I'll give it a try on Monday. |
Is there a way to mock a system package, e.g. net.Addr?
Manually, I would run the following command:
mockgen -destination=addr.go net Addr
In bazel_gomock, however, the source is a bazel target and can't be set to "net".
The text was updated successfully, but these errors were encountered: