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: need to restart gopls until it works on a newly created file (sometimes?) #33321

Closed
stapelberg opened this issue Jul 27, 2019 · 2 comments
Labels
Milestone

Comments

@stapelberg
Copy link
Contributor

@stapelberg 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 label Jul 27, 2019
@muirdm

This comment has been minimized.

Copy link

@muirdm 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

This comment has been minimized.

Copy link
Contributor Author

@stapelberg stapelberg commented Jul 29, 2019

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=
@stapelberg stapelberg closed this Jul 29, 2019
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
3 participants
You can’t perform that action at this time.