-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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/gopls: "could not import ___" after adding new _test package #36635
Comments
Change https://golang.org/cl/215743 mentions this issue: |
As usual, in debugging the creation of a new file with gopls, I've encountered a go/packages overlay bug. The issue is: A file b/b.go with package name "b" exists on disk. A package b/b_test.go with no content exists on disk. There is an overlay for b/b_test.go that contains the package name "b". Running packages.Load for file=b/b_test.go will result in a failure to load package b [b.test]. This change adds this test to the go/packages tests. This case is fixed by restricting the fallback logic in runContainsQueries. We only attempt to construct an ad-hoc package if the original package was returned with no GoFiles. Also, a minor change to the gopls error parsing code that fixes a case in which diagnostics were being sent without corresponding files. Updates golang/go#36635. Change-Id: I38680a2cc65ae9c3252294db6b942d031189faf5 Reviewed-on: https://go-review.googlesource.com/c/tools/+/215743 Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com> Reviewed-by: Michael Matloob <matloob@golang.org>
This issue is a combination of #35973 and #36661. With Go 1.14, the imports no longer disappear, since that fix is available there. The fact that we don't recover from the imports disappearing can be attributed to this fact (#36661 (comment)):
I will then close this issue and continue work on modifying the workspace packages set on #36661. |
On the further investigation, the issue persists apart from what #36661 covers. I will keep investigating, but as it already existed in |
The main issue here is that these tests in package bad
import "fmt"
func hello() {
fmt.Println("hello")
} Then, create the corresponding test file in VS Code. It will be prepopulated if you create it through the VS Code UI. Running /cc @heschik Also worth noting that running the gopackages -json -deps -test ~/bad/bad_test.go
{
"ID": "command-line-arguments",
"PkgPath": "command-line-arguments",
"Errors": [
{
"Pos": "",
"Msg": "bad_test.go:1:1: expected 'package', found 'EOF'",
"Kind": 1
}
]
} |
I believe the problem is that |
Change https://golang.org/cl/216141 mentions this issue: |
Change https://golang.org/cl/216141 mentions this issue: |
Please answer these questions before submitting your issue. Thanks!
What did you do?
I created a package, added code to it, then added a
_test
package to the same directory.What did you expect to see?
No errors, I can start working on that package.
What did you see instead?
On finishing typing my package name, all of the imports in my non-test code had "could not import" errors.
Logs: https://gist.github.com/zikaeroh/6ba035d30a5493e19e8673b47ace4f7c
Build info
Go info
The text was updated successfully, but these errors were encountered: