Skip to content

x/tools/gopls: need to restart gopls until it works on a newly created file (sometimes?) #33321

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

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

Comments

@stapelberg
Copy link
Contributor

stapelberg commented Jul 27, 2019

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

$ go version
go version go1.12.4 linux/amd64
$ gopls version
golang.org/x/tools/gopls v0.1.2
    golang.org/x/tools/gopls@v0.1.3 h1:CB5ECiPysqZrwxcyRjN+exyZpY0gODTZvNiqQi3lpeo=

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=""
GOCACHE="/home/michael/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/michael/go"
GOPROXY=""
GORACE=""
GOROOT="/home/michael/sdk/go1.12.4"
GOTMPDIR=""
GOTOOLDIR="/home/michael/sdk/go1.12.4/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build159176988=/tmp/go-build -gno-record-gcc-switches"

What did you do?

  1. mkdir /tmp/repro
  2. cd /tmp/repro
  3. emacs repro.go
  4. In the Emacs mini buffer, I’m seeing LSP :: no AST for file:///tmp/repro/repro.go
  5. Enter “package main” and save the file.
  6. gopls-powered features still don’t work (e.g. jump-to-definition when adding func a() {} func b() { a() } and placing the cursor on a().

To make gopls work, it is not sufficient ot re-open the file. I need to kill gopls and restart it.

I’m attaching logfiles of this working (seems to work sometimes, but not always) and not working:

lsp-broken.log
lsp-working.log

cc @stamblerre

@gopherbot gopherbot added this to the Unreleased milestone Jul 27, 2019
@gopherbot gopherbot added the gopls Issues related to the Go language server, gopls. label Jul 27, 2019
@muirdm
Copy link

muirdm commented Jul 27, 2019

I wasn't able to reproduce this problem. I see errors but once I save the file after typing "package main" things work properly (note that things work properly even without saving if I first go mod init repro).

The AST for file:///tmp/repro/repro.go has an invalid position errors in lsp-broken.log reminded me of https://go-review.googlesource.com/c/tools/+/185839. Can you see if you can reproduce the issue with gopls on master?

@stapelberg
Copy link
Contributor Author

Indeed this seems fixed with gopls@master. Specifically, I’m now using:

% gopls version
golang.org/x/tools/cmd/gopls v0.1.3-cmd.gopls
    golang.org/x/tools@v0.0.0-20190729092621-ff9f1409240a h1:mEQZbbaBjWyLNy0tmZmgEuQAR8XOQ3hL8GYi3J/NG64=

@golang golang locked and limited conversation to collaborators Jul 28, 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

3 participants