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

x/tools/gopls: import errors are not disappearing on first file of project #37195

Open
ridersofrohan opened this issue Feb 12, 2020 · 1 comment
Open

Comments

@ridersofrohan
Copy link

@ridersofrohan ridersofrohan commented Feb 12, 2020

When I create a new project, I run go mod init and then create the first .go file for that package. I first type

package main

then proceed to type

func main() {
	log.Println("HERE")
}

When I hit save, the import log shows up, which is correct but then the error on the log.Println() does not disappear.

The error messages that keep coming up are: "getting file for AllImportsFixes: command-line-arguments has no metadata" and "diagnose: no workspace packages: command-line-arguments has no metadata".

This issue seems to be on go/packages/golist.go#L289 and seems to be caused from falling back to using an ad-hoc package is there is an error loading the package, I think the problem here is that if the file does not have a package line yet, then the package that gets returned from go/packages will be "command-line-arguments". gopls caches this package and attempts to keep loading this package on file changes and never gets any metadata back.

@ridersofrohan ridersofrohan added this to the gopls/v0.4.0 milestone Feb 12, 2020
@golang golang deleted a comment from gopherbot Feb 13, 2020
@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Feb 26, 2020

Change https://golang.org/cl/221222 mentions this issue: internal/lsp/regtest: add a test for diagnostics on first file

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

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.