-
-
Notifications
You must be signed in to change notification settings - Fork 111
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
document "reserved standard library" module paths #135
Comments
You seem to understand what's going on here :) Have you seen #117 (comment)? I might add that to a FAQ since this keeps coming up. |
That's planned for #38, so that would affect grouping imports too. Still, though, you shouldn't be using paths which are "reserved for std" as per the explanation above. |
friendly ping :) did you see my reply above? |
Yep -- I updated the module in question to be a github based name, not a single word. given #38 and your golang issue, I'm thinking the only thing to do here would be to update the FAQ. |
Thank you - agreed. |
I'll leave this open as a doc reminder for myself, if that's OK :) |
FYI, see #187 (comment); I'm currently thinking we could do better for everyone by looking at the main module's path. |
If I have the following directory structure:
with the following file contents:
go.mod:
main.go:
pkg/thing/thing.go:
Then gofumpt will change main.go's import block such that the foo/pkg/thing import is tied to the stdlib fmt import.
I think this is only possible to detect with the current gofumpt implementation if gofumpt reads the go.mod file to know what module it is in. If
import == module || strings.HasPrefix(import, module + "/")
, then the import is non-standard. I do not see a way to have this same logic if just relying on the ast. Another potential option is to just have a list of stdlib imports, but this obviously is not future proof for when the stdlib adds new modules (a user would have to update gofumpt, which also would then have the obligation of staying up to date with Go releases).The text was updated successfully, but these errors were encountered: