-
Notifications
You must be signed in to change notification settings - Fork 101
chore: remove duplicate imports. #3306
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think in case of dups, you should keep the named one and remove the unnamed one. The reason for naming these imports is to avoid clashes or generic names.
func foo(coin coin.Coin)
is no good 😅Not sure what the idiomatic way is, as I assume renaming imports is not very idiomatic. I am afraid it might be one letter var name like
func foo(c coin.Coin)
, but I hate short names with a passion.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.
Exactly, according to this: https://google.github.io/styleguide/go/decisions#import-renaming imports shouldn't be renamed unless there are good reasons
I don't think this is solved by renaming the package import:
func foo (coin coinpkg.Coin)
doesn't look much better imho. In general having a typeCoin
in a packagecoin
will inevitably leads us to situations like these.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.
I should have been more specific. It's not the optics, it's about the name shadowing. Inside the
foo
function you can't use thecoin
package anymore b/c it's shadowed by thecoin
argument. It's a bit silly that vars and packages live in the same namespace in Go, but since it is, we should not shadow.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.
I'd personally argue that it is better to rename the argument rather than the package (smaller scope, and it's easier to find a more meaningful name for an arg rather than a pkg) but I will not fight over it :D I'll make the changes!
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.
It's not a fight 😄 I think your point makes sense and I'm okay with it too.