-
Notifications
You must be signed in to change notification settings - Fork 812
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
Switch to gci, so we can actually auto-group imports #5493
Changes from 5 commits
4ff2686
7665b06
4fa204e
9c7a534
19eee6c
2e9b822
1b4a1cc
2b657ea
a19b6d0
991ad4b
968093f
d099971
f4fa916
ddfc80e
1bdd7f8
d95cef7
74712e8
e9db9b5
d65b4f5
b310308
ba13b03
35ba535
554f600
a14c7e2
62528e6
5ccb6ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
gofancyimports doesn't format, and it conflicts with goimports (which does format).
so now we have "normal" gofmt use.
perhaps we should add
-s
to thegofmt
command? all it's doing at the moment is removing a bunch of redundant types likesome of which are ever-so-slightly odd looking to my eyes, though it follows the same pattern:
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 guess this is the issues with fancyimports. I wonder how we can use the same logic in IDEs.
Maybe we can create a wrapper that does goimports + fancyimports afterwards?
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.
to be clear, removing goimports and using gofmt is not a problem. this is just the motivation. gofmt is faster than goimports, and gofancyimports takes care of the imports that gofmt doesn't touch.
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.
ah, for IDEs: should definitely be possible, though unlike goimports it needs to be in addition to gofmt, it's not a replacement. combining those might require a small wrapper-binary 🤔 . at the very least though, them doing different things does mean that the order doesn't matter, which is good.
though since it's an Analyzer, it should integrate into gopls just fine.
a combined-binary might be reasonable to add to gofancyimports, for IDE purposes. GoLand has a "goimports-like" formatting option which acts a lot like this too.
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.
After this lands, what should we all use as Format Tool in IDE?
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.
Just goimports with -local afaict. I honestly disable this though, IDE formatting does funky and incorrect things kinda frequently.
Or the same thing as the makefile does, if you want true stability and it can run arbitrary binaries
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.
from some side chats: we'll probably bundle a formatter-wrapper to simplify vscode and maybe other tools.
that's a bit easier to discover and fix after it's merged though, so I'm just going to skip it for now.
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.
similar stuff with gci due to unused-import cleanup, but this does also
gofmt
so a custom wrapper to run both is probably less needed - IDEs often detect and warn and offer to clean those up separately.