-
Notifications
You must be signed in to change notification settings - Fork 609
Mock import contains "vendor" directory. #30
Comments
Same issue. We've resorted to inserting a
Where I've looked over the mockgen.go code, and I can't find a clean place to make this fix (though I didn't spend that much time looking), else I'd put in a PR to fix it. |
@PawelAdamski @kaedys you might want to try #28 |
@rgarcia Thanks |
The mockgen tool doesn't properly handle[0] Go 1.5 style vendored dependencies and will emit broken `import`s. We work around this with sed and tears. [0] - golang/mock#30
Just ran into this issue myself and want to share my workaround as it seems to be a little bit more simple than using Since we use
When generate runs mockgen, mockgen doesn't recognize there being a vendor directory as it's obscured temporarily. It then correctly resolves the dependencies and generates the correct import statements. Of course, your directory names and go generate command might differ, but the concept should be portable as a simple workaround. (Might also be a hint towards a solution to the bug.) |
@jecolasurdo doesn't that break if the vendored libraries are not present in your gopath, or cause unpredictable results if you have a different version of the libraries in your gopath? Mockgen functions by creating a new go program (programmatically using the Anyway, #28 already has a fix for the issue, it just seems to have died in PR. |
#28 is now merged. @PawelAdamski I believe that fixes your issue. |
LGTM thanks @mandazi |
It seems that we are hitting the bug described in [1]. As the fix has not yet been fixed, we would fix it manually for the time being. [1] golang/mock#30
I'm running into this issue again. |
I'm generating mocks using
go generate
command://go:generate mockgen -destination=../../stripe/mock.go -package=stripe bitbucket.org/____/go-lib/model/payment Client
In resulting file imports are:
Problematic one is stripe_go which should be github.com/stripe/stripe-go
I tried to add '-imports=stripe_go=github.com/stripe/stripe-go' and '-imports stripe_go=github.com/stripe/stripe-go' but it didn't helped.
The text was updated successfully, but these errors were encountered: