Skip to content
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: import and arg collision #219

Merged
merged 1 commit into from
Oct 28, 2024

Conversation

bstncartwright
Copy link
Contributor

Resolves #218

This is my first time contributing to this project, please let me know if there is anything I need to change. Thanks!

@HassanCehef
Copy link

I'm not a maintainer; I reported the bug.

I like the fix. Name collisions have always been possible: they didn't happen so much because "arg0"..."arg5" are not usual package names.
How about using this as a suffix rather than a full replacement?
DoThat(internalpackage int): instead of becoming

-func (m *MockMything) DoThat(arg0 int) internalpackage.FooExported {
+func (m *MockMything) DoThat(internalpackage_arg0 int) internalpackage.FooExported {

this way we still get the v0.5.0 feature that provides human readable names when using mocks in all cases.

@bstncartwright
Copy link
Contributor Author

I'm not a maintainer; I reported the bug.

I like the fix. Name collisions have always been possible: they didn't happen so much because "arg0"..."arg5" are not usual package names. How about using this as a suffix rather than a full replacement? DoThat(internalpackage int): instead of becoming

-func (m *MockMything) DoThat(arg0 int) internalpackage.FooExported {
+func (m *MockMything) DoThat(internalpackage_arg0 int) internalpackage.FooExported {

this way we still get the v0.5.0 feature that provides human readable names when using mocks in all cases.

Interesting, I like that idea but I wonder if it could cause more confusion. Auto-complete from the LSP could show internalpackage_arg0 and the developer might think it is an argument of that package? Just a thought, I am open to finding the best answer here!

Copy link
Contributor

@tchung1118 tchung1118 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment. Also, could you re-generate existing test mocks?

mockgen/mockgen.go Outdated Show resolved Hide resolved
@bstncartwright
Copy link
Contributor Author

Added a comment. Also, could you re-generate existing test mocks?

Done. Thanks for your review!

Copy link
Contributor

@tchung1118 tchung1118 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you for your contribution!

@tchung1118 tchung1118 merged commit eb67641 into uber-go:main Oct 28, 2024
3 checks passed
@bstncartwright bstncartwright deleted the fix/arg-package-conflict branch October 28, 2024 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

v0.5.0 mock generated do not compile due to name clash
3 participants