-
-
Notifications
You must be signed in to change notification settings - Fork 113
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
Optional flag to disable all import sorting? #120
Comments
gofumpt also have |
Ah, gofumports no longer exists. |
@karelbilek That would certainly have been worth a look, but it's been removed. Worst case scenario I could fork it and remove the import sorting functionality entirely, I guess. |
I see. :( |
well one way to your original problem is... to just create a manual script that does both, in the order gofumpt-goimports, and put it to path... |
That's what I was trying too actually. In GoLand, chaining them together using either |
What you're running into here is unrelated to I plan on enhancing the feature with #38, but that wouldn't change the logic to join all standard library imports, nor would it mean adding a Hope that clarifies things. I know it's confusing and perhaps frustrating, but I don't think supporting reserved module paths makes sense in the long run :) |
@mvdan the module prefixes aren't actually I had a look at this project's code, and noticed something different with the go.mod file - your module name is I had a quick play around with renaming the module name to start with a domain name, and while it produced a gigantic diff, it seems to play nicely with So this issue is resolved for me now, thanks for the help! |
Right, what I meant is that not using a domain name - not having a dot - means that you're using a path reserved by the Go toolchain, for paths like the standard library. So gofumpt assumes it's std. Glad that worked for you :) Closing. |
FYI, see #187 (comment); I'm currently thinking we could do better for everyone by looking at the main module's path. |
Add the feature, test it, and document it in the README. It's enough to mention it in the FAQ, as I expect that most users will never run into this edge case. And those few that may run into it will hopefully never need to know how it works or why. Note that this adds a new option to pass the info from go.mod, much like LangVersion already did. Fixes #22. Fixes #117. Fixes #120. Fixes #187.
Add the feature, test it, and document it in the README. It's enough to mention it in the FAQ, as I expect that most users will never run into this edge case. And those few that may run into it will hopefully never need to know how it works or why. Note that this adds a new option to pass the info from go.mod, much like LangVersion already did. Fixes #22. Fixes #117. Fixes #120. Fixes #187.
Add the feature, test it, and document it in the README. It's enough to mention it in the FAQ, as I expect that most users will never run into this edge case. And those few that may run into it will hopefully never need to know how it works or why. Note that this adds a new option to pass the info from go.mod, much like LangVersion already did. Fixes #22. Fixes #117. Fixes #120. Fixes #187.
I'm sure the default settings work for many, but when looking at this tool, it doesn't let you set a
local
prefix, likegoimports
does. As such, I am looking for a way to usegoimports
in conjunction withgofumpt
.I set them both up as file watchers in GoLand, but the issue there is that
goimports
is much faster, and always finishes first. Which makes the file's imports nice for a second. Thengofumpt
finishes, and undoes all the imports sorting done bygoimports
, with it's mangled version.So for example,
goimports -local abc -w $FilePath
formats like this:gofumpt
formats it like this:So is there a way to skip the imports sorting entirely, and leave that to
goimports
? If not, and if it's doable, I would appreciate pointers as to how to get that done!Ideally this just passes on the
local
arg togoimports
, which might solve the issue of overwriting as well. Even if this didn't touch the imports block at all, I'm not entirely sure if the conflicting finish times would be an issue or not still.PS I love the tool, and have been manually enforcing a few of the rules already, and agree with most of the other rules. Just a shame it's incompatible with how the project currently formats imports, or we would be using it already :)
The text was updated successfully, but these errors were encountered: