-
Notifications
You must be signed in to change notification settings - Fork 609
go generate fails to mockgen on go 1.14 #415
Comments
Please update your generate command to look like this: Notable added: That did the trick for me /w the latest mockgen and 1.14 😄 |
Afraid that doesn't work for me @codyoss, running
sorry, I should have mentioned that |
Thank you for the minimal working example @Callisto13!! Helped me a lot when I tried to reproduce the bug. TL;DR: Go 1.13 and below would still pick up from the import (
_ "github.com/golang/mock/mockgen/model"
) After some investigation, I think that what happens is that when you run Let's see step by step
Quite an unpleasant workaround I must admit 🙄 |
Thanks @maelvls! I experimented with this last week and came to almost the same conclusion. Unfortunately importing
Having any fake import is a rather unpleasant hack so I am hoping the folks at gomock can suggest something less awful. |
I am not sure I have a great solution for this. To get the 1.13 behavior I think you have use a You have to pick if you want the go tooling to properly respect the vendor folder, only on partially. I am thinking the former is what most people will want. With modules I think people are going to find having something like a tool.go file, where there are some underscore imports quite helpful, for reproducible builds. I don't think this is a bad pattern to use. This is nice to make sure things like goimports is in your CI system. Here is an example from another project I work on: https://github.com/googleapis/google-cloud-go/blob/master/tools.go |
I just tried the
|
Actual behavior.
On go 1.14.
Running
go generate ./...
when thevendor
dir is present fails with:(I am guessing this is because
mockgen
depends on some runtime thing being there which would not be included when vendoring.)We saw this appear after bumping to go 1.14. On go 1.13.x
go generate
ran fine.Expected behavior
My mocks should be generated and no error should occur.
To Reproduce
I have set up a dumb example repo which mimics how we generate mocks in our codebase.
Silly interfaces found in
dinosaur/dinosaur.go
. Mocks should be generated inmocks/mock_dino.go
.To create mocks we keep a
doc.go
file inmocks/
and set the mocks to be generated in that package using the format:git clone https://github.com/Callisto13/cretaceous && cd cretaceous
vendor
dir is not present.go generate ./...
works happily.go mod vendor
go generate ./...
fails with the error noted above.vendor
dir and run through again for lolz.vendor
dir present.The behaviour is seen on all my team's machines.
Additional Information
Triage Notes for the Maintainers
The text was updated successfully, but these errors were encountered: