golang / mock

GoMock is a mocking framework for the Go programming language.
Apache License 2.0
9.3k stars 610 forks source link

allow for overriding source package #529

Closed choo-stripe closed 3 years ago

choo-stripe commented 3 years ago

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.

codyoss commented 3 years ago

@choo-stripe Would you please open a feature request for this PR. We like to have discussion before implementing any features.

choo-stripe commented 3 years ago

Done: https://github.com/golang/mock/issues/531

codyoss commented 3 years ago

Closing in favor of #547