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: cannot import public symbols defined behind build tags #38963

Closed
perrito666 opened this issue May 8, 2020 · 2 comments
Closed

x/tools/gopls: cannot import public symbols defined behind build tags #38963

perrito666 opened this issue May 8, 2020 · 2 comments
Labels
Milestone

Comments

@perrito666
Copy link

@perrito666 perrito666 commented May 8, 2020

Please answer these questions before submitting your issue. Thanks!

What did you do?

I created a proof of concept repo for this, https://github.com/perrito666/goplshatestags
I find this being reproduced on VSCode (the way I use gopls) I basically have a file inside a package that has a build tag // +build unit that declares public test helper functions

  • When importing said package from the tests of other packages, gopls complains about the functions not being declared in the package
  • When using things from one test file into another within the same package, everything declared behind the tags also fails to be found by gopls.
    I added the tag to every possible configuration where it fits and the problem persists, I suspect gopls is at fault

I also suplied the log in https://github.com/perrito666/goplshatestags/blob/v0.1.1/goplslog.log

What did you expect to see?

At least "go to definition" of my functions defined behind tags

What did you see instead?

I think the actual error is:

[Error - 4:48:17 PM] Request textDocument/definition failed.
  Message: getting file for Identifier: no PackageHandles
  Code: 0 

Build info

golang.org/x/tools/gopls 0.4.0
    golang.org/x/tools/gopls@v0.4.0 h1:G4+YP9kaV4dJb79J5MobyApxX493Qa6VoiTceUmxqik=
    github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
    github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
    golang.org/x/mod@v0.2.0 h1:KU7oHjnv3XNWfa5COkzUifxZmxp1TyI7ImMXqFxLwvQ=
    golang.org/x/sync@v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY=
    golang.org/x/tools@v0.0.0-20200407041343-bf15fae40dea h1:DUwLyMDMUauGMd9kSLIlhhYJNELm06HuxeBdkFkeax4=
    golang.org/x/xerrors@v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
    honnef.co/go/tools@v0.0.1-2020.1.3 h1:sXmLre5bzIR6ypkjXCDI3jHPssRhc8KD/Ome589sc3U=
    mvdan.cc/xurls/v2@v2.1.0 h1:KaMb5GLhlcSX+e+qhbRJODnUUBvlw01jt4yrjFIHAuA=

Go info

go version go1.13.8 darwin/amd64

@gopherbot gopherbot added this to the Unreleased milestone May 8, 2020
@gopherbot
Copy link

@gopherbot gopherbot commented May 8, 2020

Thank you for filing a gopls issue! Please take a look at the Troubleshooting guide, and make sure that you have provided all of the relevant information here.

@perrito666
Copy link
Author

@perrito666 perrito666 commented May 8, 2020

Fixed by adding GOFLAGS=-tags=unit to the config

@perrito666 perrito666 closed this May 8, 2020
perrito666 added a commit to perrito666/tools that referenced this issue May 8, 2020
As prompted [this issue](golang/go#38963) it
is unclear how to setup build tags in gopls in vscode.
vscode has a configuration section specific for go build tags but it is
not honored by gopls which instead requires GOFLAGS environment variable
to be set with the -tags flag.
gopherbot pushed a commit to golang/tools that referenced this issue May 8, 2020
As prompted [this issue](golang/go#38963) it
is unclear how to setup build tags in gopls in vscode.

vscode has a configuration section specific for go build tags but it is
not honored by gopls which instead requires GOFLAGS environment variable
to be set with the -tags flag.

Change-Id: Ib74a5bca78bf222d73224590ee0344948f020f9f
GitHub-Last-Rev: 37d1f9f
GitHub-Pull-Request: #227
Reviewed-on: https://go-review.googlesource.com/c/tools/+/233018
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
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
2 participants
You can’t perform that action at this time.