We call mockgen from bazel, which lives in a hermetic environment and doesn't have access to go modules or GOPATH. However, we shouldn't really need to magically find the name of the go package.
This PR adds a flag to override the source package - so that if the mock file needs to import from the original file, it'll use the provided package.
I looked at writing tests. I didn't put this in parsePackageImport because that function is called in multiple places, including to determine the destination path. We don't want to override the destination path. I thought about creating a new function, getPackageName or something, but it didn't seem worthwhile.
Greetings!
We call
mockgen
from bazel, which lives in a hermetic environment and doesn't have access to go modules or GOPATH. However, we shouldn't really need to magically find the name of the go package.This PR adds a flag to override the source package - so that if the mock file needs to import from the original file, it'll use the provided package.
I looked at writing tests. I didn't put this in
parsePackageImport
because that function is called in multiple places, including to determine the destination path. We don't want to override the destination path. I thought about creating a new function,getPackageName
or something, but it didn't seem worthwhile.