x/tools/gopls: `undeclared name` when using function from another file when both files have build tags #42257
Milestone
Comments
Please follow https://github.com/golang/tools/blob/master/gopls/doc/vscode.md#build-tags to configure the build tags you want to use. |
Setting
in |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 have a suite of integration tests files, all of which live in
cmd/integrationtests
folder, in a package namedintegrationtests
.I have a main file which includes functions for setting up the components like:
then I have different files with integration tests like
users_test.go
that use thesetup
function (without importing anything, because the function is in the same package) and it all works fine.I created a new file in the same folder and package and when I tried to use the function I got the following error from VS Code:
Screenshot from the error:

NOTE: I do see that the error is coming from
compile
, notlsp
, however when runninggo tool compile games_test.go integration_test.go
I do not get any errors and I do not expect to get any errors, because what I am trying to do is valid, and I already do it in multiple files.NOTE: The project I am working on is open source, so I can show you the package in question.
What did you expect to see?
I expected my code to be able to find the
setup
function.What did you see instead?
Error:
undeclared name: setup compiler
The text was updated successfully, but these errors were encountered: