-
Notifications
You must be signed in to change notification settings - Fork 17.5k
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: fails to load package for test file #41081
Comments
The second issue you mention is #40690. The issue with your test file is that |
Yes, the test files do use build tags. Should build tags be handled in gopls settings?. Here's the output you requested.
Perhaps it's a problem that these files show up as
|
Yes - you have to add build tags to your configuration if you are using a build tagged file. |
The setting you want is: "gopls": {
"env": {
"GOFLAGS": "-tags=<my build tag>"
}
} |
Wohoo! Totally fixes my issue. Great project, and I also loved your GopherCon talk. Keep it up! |
Thank you! 😄 |
VSCode fails to execute commands such as "Go to Definition" while using gopls on my machine for
*_test.go
files. In other words, it does not reveal the requested source code or preview for the command. Additionally, I see gopls server error logs when I open any of these files in my VSCode editor and when usinggopls check
. This is not the case in non-test files in the same packages.What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
What operating system and processor architecture are you using (
go env
)?go env
Outputgopls related VSCode settings
What did you do?
I'm not certain when or if a breakage occurred since other editors are in use on my team, but I can try to reproduce a more minimal example if this information is not enough.
What did you expect to see?
When I navigate to a file I don't expect to see RPC trace errors for the gopls server. For example, navigating to an
/internal/db_test.go
file. When I navigate to/internal/db.go
, I do not see these errors.When I click
Go to Definition
I expect the editor to navigate to the source code at defined either in the temporary modules cache or a file within the project directory. I also don't expect to see gopls errors in the RPC trace when hovering or clicking Go.Similarly, I expect
gopls check
to not return errors for test files - no errors for non-test files.gopls check /Users/dbarnard/Code/go/src/$MY_PRIVATE_REPO/$MY_PROJECT/internal/db/db.go
What did you see instead?
When I navigate to an
*_test.go
file, I see RPC and see trace errors in the gopls server. Here I'm navigating to an/internal/db_test.go
file.When I right click on a symbol defined in an external package (outside of the project repository) in
*_test.go
file, I see "No definition found for ..." any symbol in the VSCode editor. The traces for gopls server RPC trace errors are below.Here
gopls check
does return an errorFinally, this may be a separate issue but just in case it helps as context -- I seem get this error as a popup from the VSCode Go extension/gopls when I add a new package in my source code and save. Example:
Thanks in advance!
The text was updated successfully, but these errors were encountered: