-
Notifications
You must be signed in to change notification settings - Fork 611
mockgen stopped working after upgrading to Golang 1.13 #347
Comments
I will look into this, thanks for the report |
Stayed on golang 1.12 for now |
@veqryn @henry-jackson I think this is caused by the fact that 1.13 by default enables module aware behavior Under the covers, mockgen runs As a workaround, can you add to your In general, I think there should be at least better error message provided and more output so that the user user understand what mockgen does under the covers. May I also ask a bit more details about your use case? When do you run |
I believe i tried using that flag and had some problems getting it to work. I can try again this weekend and report the results. We run We run |
@veqryn Ok makes sense, thanks for explaining. The workaround also assumes that you run the mockgen from the directory where the |
That might be why it didn't work. Our |
If you run the mockgen in the context of a module (in any subdirectory of the root directory) it should work. |
@veqryn any update? |
Sorry, holidays got in the way. Will try soon |
@veqryn still having issues? |
@nguyenfilip @codyoss Examples: Here is the go generate line in my file: // Generate mocks
//go:generate mockgen --build_flags="--mod=vendor" --package=mock_seeds --destination=${GOPATH}/src/github.com/ReturnPath/seeds/go/proto/seeds/mock_seeds/mock_seeds.go github.com/ReturnPath/seeds/go/proto/seeds ExternalAPIClient,ExternalAPIServer,InternalAPIClient,InternalAPIServer,InternalAPI_MailserviceAccountsGetClient,InternalAPI_MailserviceAccountsGetServer When run:
If I run
If I remove the build flags from the mockgen line, here is the file: // Generate mocks
//go:generate mockgen --package=mock_seeds --destination=${GOPATH}/src/github.com/ReturnPath/seeds/go/proto/seeds/mock_seeds/mock_seeds.go github.com/ReturnPath/seeds/go/proto/seeds ExternalAPIClient,ExternalAPIServer,InternalAPIClient,InternalAPIServer,InternalAPI_MailserviceAccountsGetClient,InternalAPI_MailserviceAccountsGetServer If I run go generate on that, with the build flag, I get:
Here is my
And my go.mod file, located at
|
I also tried with single quotes, such as: |
@veqryn I think that the correct combination of flags for you is to have --mod=vendor in BOTH:
I think that the root cause of your problem is the same as for issue #354. In a nutshell the problem is that in Docker (because of effective root privileges) the mockgen doesn't get executed in "current directory" but it is executed first in module cache. I hope to fix that bug with #390 I will try to reproduce the combination of features (vendoring + go generate + docker) locally. I assume it is not possible that you provide a live reproducer? |
Since it requires a private repo, that is vendored, it is probably not possible for me to provide a live reproducer. What do you mean by having --mod=vendor in |
@veqryn I have prepared a sample that seems to work (see below). I think that the problem in your case is that your go:generate directive has quotes around the
The sample
To run the sample, just clone the repo and run the commands that are mentioned in the readme file. |
It looks like removing the quotes fixed the problem. I'll do some more testing, and will re-open the issue if any problems come up. Thank you! |
A few questions:
|
I resolved this issue for myself a couple weeks ago after realizing I somehow had 2 different versions of mockgen installed. I ran Might be worth trying for anyone else that is still running into similar issues |
@henry-jackson the mockgen now has a |
@veqryn good questions
|
I think an error/warning message would be great. |
We run gomock/mockgen inside of a docker container. Previously that docker container was based on golang 1.12, but we upgrade it to 1.13 today.
After upgrading to golang 1.13, mockgen started failing out:
Our project has several golang modules it depends on that are private, with the obfuscated
https://github.com/xxx/zzz
being one of them. We usego mod vendor
to commit them to the repo.Why is mockgen running
go get
orgit fetch
or anything like that?mockgen shouldn't be getting my source files, when they are all right there already.
What is going on, and how to solve it?
The text was updated successfully, but these errors were encountered: