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: not understanding package_test #32906

Closed
jeanbza opened this issue Jul 2, 2019 · 10 comments
Closed

x/tools/gopls: not understanding package_test #32906

jeanbza opened this issue Jul 2, 2019 · 10 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls.
Milestone

Comments

@jeanbza
Copy link
Member

jeanbza commented Jul 2, 2019

What version of Go are you using (go version)?

$ go version
go version go1.12.5 linux/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOARCH="amd64"
GOBIN="/usr/local/google/home/deklerk/dev/go1.12.5.linux-amd64/go/bin"
GOCACHE="/usr/local/google/home/deklerk/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/usr/local/google/home/deklerk/workspace/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/google/home/deklerk/dev/go1.12.5.linux-amd64/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/google/home/deklerk/dev/go1.12.5.linux-amd64/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/usr/local/google/home/deklerk/workspace/google-cloud-go/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build430311602=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Using vscode with Go@0.11.0 plugin. Have package bigtable, create a new file conformance_test.go with package bigtable_test declaration.

What did you expect to see?

No problems in editor.

What did you see instead?

Red squiggly under package with text:

package bigtable_test; expected bigtable LSP
@gopherbot gopherbot added the gopls Issues related to the Go language server, gopls. label Jul 2, 2019
@jeanbza
Copy link
Member Author

jeanbza commented Jul 2, 2019

FYI, this is doubly annoying because it prevents any other interpretation of the file. So, unless I rename this package bigtable, there is no LSP on the entire file, rendering my editor mostly-useless.

@stamblerre stamblerre changed the title lsp: not understanding package_test x/tools/gopls: not understanding package_test Jul 2, 2019
@gopherbot gopherbot added this to the Unreleased milestone Jul 2, 2019
@stamblerre stamblerre added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jul 2, 2019
@stamblerre
Copy link
Contributor

What version of gopls are you using (gopls version)? What happens when you save the file - does the error ever go away?

@jeanbza
Copy link
Member Author

jeanbza commented Jul 2, 2019

Not sure:

$ gopls version
no module information, gopls not built in module mode

So, I blew that binary away, reset everything I could in vscode, and performed:

go get golang.org/x/tools/gopls@latest

Now it seems to accept bigtable_test. Huzzah!

@jeanbza jeanbza closed this as completed Jul 2, 2019
@jeanbza
Copy link
Member Author

jeanbza commented Jul 2, 2019

Whoops, spoke too soon. Now I get an error at the first character of the file with the following:

file:///usr/local/google/home/deklerk/workspace/google-cloud-go/bigtable/conformance_test.go is not part of a package LSP

edit: Once again, changing package bigtable_test to package bigtable fixes this.

edit2:

$ gopls version
golang.org/x/tools/gopls v0.1.0
    golang.org/x/tools/gopls@v0.1.1 h1:mU/O8r53RjzdZfkqmFOX4iEt8PJxTPXyLdiuQNa27OE=

@jeanbza jeanbza reopened this Jul 2, 2019
@ogimenezb
Copy link

Same problem here with VSCode

$ gopls version
golang.org/x/tools/gopls v0.1.0
    golang.org/x/tools/gopls@v0.1.1 h1:mU/O8r53RjzdZfkqmFOX4iEt8PJxTPXyLdiuQNa27OE=

@stamblerre
Copy link
Contributor

Can you try reproducing this on master (go get -u golang.org/x/tools/gopls@master)? We will likely be tagging a new version of gopls soon, but for now, the fix may already be on master.

@ogimenezb
Copy link

Hi,

Still the same problem.

/const.go is not part of a package LSP

$ gopls version
golang.org/x/tools/gopls v0.1.1
    golang.org/x/tools/gopls@v0.1.2-0.20190708203411-c8855242db9c h1:qFHl9H1pFOvam5c7rRNiSVPuASu5sS/VNZUj7KNAyGI=

@ogimenezb
Copy link

ogimenezb commented Jul 9, 2019

I have been doing some more testing.

If I have a package and have, for example

argon.go -> package passwords
argon_test.go -> package passwords_test

Work well, but If I have the same and is using cgo, Then I have the problem
As an example I add:

package passwords

/*

#cgo CFLAGS: -std=gnu99
*/
import "C"

argon.go is not part of a package LSP

Sorry didn't realize sooner, working on a cgo project for the last couple of weeks

@jeanbza
Copy link
Member Author

jeanbza commented Jul 9, 2019

Seems to work on master for me.

@stamblerre
Copy link
Contributor

@ogimenezb: Your issue sounds more like #31561.
I will close this issue in favor of that one.

@stamblerre stamblerre removed the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 6, 2019
@golang golang locked and limited conversation to collaborators Aug 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls.
Projects
None yet
Development

No branches or pull requests

4 participants