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
x/tools/imports: doesn't add import for ast.Expr #34199
Comments
Thank you for filing a gopls issue! Please take a look at the Troubleshooting section of the gopls Wiki page, and make sure that you have provided all of the relevant information here. |
Not (just) a gopls bug, renamed. |
Huh.
We take the API files and turn them into |
Change https://golang.org/cl/194568 mentions this issue: |
This comment has been minimized.
This comment has been minimized.
In api/*.txt, interface declarations are represented with lines like: pkg container/heap, type Interface interface { Len, Less, Pop, Push, Swap } or, when they have no exported methods: pkg go/ast, type Expr interface, unexported methods The latter form confuses mkstdlib into thinking that it's a method because of the extra comma, and then it skips the interface entirely. Running this program is a matter of seconds once per release, so rather than trying to fix the optimization, just remove it. The parsing logic doesn't care about the extra lines. And the corresponding change to the copy in lsp/testdata/unimported. Updates golang/go#34199 Change-Id: Ic34b8a47537608401e4ef6683617d797f9f50f8a Reviewed-on: https://go-review.googlesource.com/c/tools/+/194568 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Change https://golang.org/cl/194570 mentions this issue: |
In api/*.txt, interface declarations are represented with lines like: pkg container/heap, type Interface interface { Len, Less, Pop, Push, Swap } or, when they have no exported methods: pkg go/ast, type Expr interface, unexported methods The latter form confuses mkstdlib into thinking that it's a method because of the extra comma, and then it skips the interface entirely. Running this program is a matter of seconds once per release, so rather than trying to fix the optimization, just remove it. The parsing logic doesn't care about the extra lines. And the corresponding change to the copy in lsp/testdata/unimported. Updates golang/go#34199 Change-Id: Ic34b8a47537608401e4ef6683617d797f9f50f8a Reviewed-on: https://go-review.googlesource.com/c/tools/+/194568 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Go 1.13 introduced a module in GOROOT/src. That triggered goimports to think that it was an invalid module, usable only as a replace target, because its declared module path "std" didn't match its apparent path "src". The stdlib is always in scope, so skip the needs-replace check for GOROOT. Fixes golang/go#34199 Change-Id: I1199378b940cfedc04e9a4e943c46b9ffdf18446 Reviewed-on: https://go-review.googlesource.com/c/tools/+/194570 Run-TryBot: Heschi Kreinick <heschi@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Cottrell <iancottrell@google.com>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I ran organize imports on below file:
What did you expect to see?
I expected it to add an import for "go/ast".
What did you see instead?
No import added. goimports works, and mysteriously organize imports works if you change it to ast.Node.
The text was updated successfully, but these errors were encountered: