Skip to content
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

Import grouping vs internal #307

Closed
kolyshkin opened this issue Jul 1, 2024 · 5 comments
Closed

Import grouping vs internal #307

kolyshkin opened this issue Jul 1, 2024 · 5 comments

Comments

@kolyshkin
Copy link

When working on the code in https://github.com/golang/go, gofumpt insists on placing imports of packages with internal/ prefix to a separate group. Here's an example:

diff --git a/src/os/os_test.go b/src/os/os_test.go
index 9519aa0fc6..01f7932e4f 100644
--- a/src/os/os_test.go
+++ b/src/os/os_test.go
@@ -9,7 +9,6 @@ import (
        "errors"
        "flag"
        "fmt"
-       "internal/testenv"
        "io"
        "io/fs"
        "log"
@@ -26,6 +25,8 @@ import (
        "testing"
        "testing/fstest"
        "time"
+
+       "internal/testenv"
 )

@ianlancetaylor mentioned that this is not how they want their code to be formatted.

If this is by design, please close.

@ianlancetaylor
Copy link

Note that this is a special case for the Go standard library only.

@mvdan
Copy link
Owner

mvdan commented Jul 13, 2024

Thanks for the report. I added logic to treat test/ and example/ import path prefixes as non-std when golang/go#37641 was proposed, and for some reason, I also did internal/ prefixes then, with the comment that "they are unreachable". I'm not sure what I meant back then, but it doesn't make sense to me now :)

Indeed, std does contain some top-level internal packages, and they are still part of std, even if third party Go modules cannot import them directly. Will fix shortly.

@mvdan mvdan closed this as completed in 5aa7546 Jul 13, 2024
@kolyshkin
Copy link
Author

Thank you @mvdan; can we please have v0.6.1? 🙏🏻

@mvdan
Copy link
Owner

mvdan commented Jul 19, 2024

I'll do a v0.7.0 just before Go 1.23 is out, syncing with cmd/gofmt as well.

@kolyshkin
Copy link
Author

I'll do a v0.7.0 just before Go 1.23 is out, syncing with cmd/gofmt as well.

@mvdan very please 🙏🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants