-
Notifications
You must be signed in to change notification settings - Fork 606
Cannot install and run mockgen from the vendor directoryΒ #95
Description
We would like to "vendorize" mockgen
in our project, in order to freeze the version we are using and prevent unexpected breakages. We already do this with gomock
for the same reason. We use govendor
for this.
We vendorize gomock
with govendor fetch github.com/golang/mock/[email protected]
. Then, we can install mockgen
from the vendor/
directory using govendor install +vendor
. However, when we try to run mockgen
, we get the following output:
prog.go:11:2: cannot find package "github.com/golang/mock/mockgen/model" in any of:
/usr/local/Cellar/go/1.8.3/libexec/src/github.com/golang/mock/mockgen/model (from $GOROOT)
/<omitted>/go/src/github.com/golang/mock/mockgen/model (from $GOPATH)
This is obviously because the package github.com/golang/mock/mockgen/model
is not at the mentioned locations, but under our vendor/
directory. One way to fix this is to run go get -u github.com/golang/mock/mockgen
, which places the model
package under $GOPATH
. Another way is to run govendor get -u github.com/golang/mock/[email protected]
, which is what we currently do. The advantage to "vendorizing" it as described above is that it centralizes the version management with the rest of our dependencies.
Why is there a runtime dependency on this model
package? Shouldn't it be compiled into the mockgen
binary? Is there any way to install mockgen
from the vendor directory?