-
Notifications
You must be signed in to change notification settings - Fork 607
-self_package does not work when -package is different from the base dir of package path #342
Comments
Thanks for the report, I will check out your PR soon here! |
I don't think there is an issue here, or at least not with the example you have given. In this example your interface returns a struct, The output that makes this required: // getInfo mocks base method
func (m *MockMethods) getInfo() interfaces.Info {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "getInfo")
ret0, _ := ret[0].(interfaces.Info)
return ret0
} Thoughts? |
This is only true when the mock is going to be compiled in a different package. However, the intention here, by specifying Is this a valid use of the |
Thanks for the clarification. I did not realize the import path did not match package name For now as a workaround this should work: Still thinking about the change, just want to make sure if does not break other things. |
Yes, source mode works as a workaround. However, source mode is slower under bazel_gomock rule, as it requires constructing a GOPATH in the sandbox. Thanks for looking into this. |
Fixed with #343. |
Steps to reproduce:
mockgen -package core -self_package github.com/linzhp/go_examples/interfaces github.com/linzhp/go_examples/interfaces Methods
What do I expect:
The generated mock should not import
github.com/linzhp/go_examples/interfaces
because it is specified in-self_package
What do I see instead:
The text was updated successfully, but these errors were encountered: