You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I agree with your sentiment here - and I would imagine that gopls might already do this as part of its "organize imports" action, or it might already have a feature request for it - gofumpt works only on the syntax files so it doesn't process imported packages in any way, which would be required for this to work. That would make the tool significantly more complex and slower, and it's not really about formatting, so I think it's out of scope.
When the import path doesn't match the package name, it's a good idea to alias the import to be more explicit.
Here's an example with
github.com/testcontainers/testcontainers-go
(which defines a packagetestcontainers
):should be aliased to
Both imports are equivalent, because in both files, package can be accessed as
testcontainers
.On the other hand, if the package is already aliased like in the following example,
gofumpt
should not change the alias:The text was updated successfully, but these errors were encountered: