-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: define imported package's local name by using flags #41
Conversation
…interface names comment (uber-go#33) Fix uber-go#32
I ran into this bug today for the first time (in the old gomock/mockgen package). It's frustrating the import names get broken in the generated mocks when using import aliases or dot imports and it would be great to see this fixed. |
Erfan Momeni seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
|
||
//go:generate mockgen -package defined_import_local_name -destination mock.go -source input.go -imports b_mock=bytes,c_mock=context | ||
|
||
type WithDotImports interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add an additional package to test for stdlib and external imports?
Suggestion: Update the method names to reflect which scenario being tested.
|
||
//go:generate mockgen -package defined_import_local_name -destination mock.go -source input.go -imports b_mock=bytes,c_mock=context | ||
|
||
type WithDotImports interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is DotImports referring to? In the spec I see three cases
Import declaration Local name of Sin
import "lib/math" math.Sin
import m "lib/math" m.Sin
import . "lib/math" Sin
As a reviewer, the DotImport name makes me think this is that last case in the list, but this test seems to be testing named imports (case 2).
Dear @r-hang, you are correct. I have renamed it to |
fixes #646,
Hi, my friends.
Merging this pull request can fix old bugs related to defining the local names of imported packages by using the -imports flag.
I have also added a test for that, and it works properly.
If you have any ideas or concerns regarding the PR, feel free to tell me.