go: x/tools/gopls: begins to fail after some use

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

$ go version
go version go1.12.3 darwin/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="/Users/tonio/Documents/Aporeto/workspace/code/go/bin"
GOCACHE="/Users/tonio/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/tonio/Documents/Aporeto/workspace/code/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.12.3/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.12.3/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/f1/_f3ghgmj7l352ypkbkjkxd7w0000gn/T/go-build905666433=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I pulled latest after a week or two

What did you expect to see?

Gopls to work

What did you see instead?

Using VSCode, I have to reload everything for gopls to work every 2m or so. Otherwise I get random errors:

  • file X is not part of a package
  • package X does not implement Y (while it’s been their forever)
  • continuously reports error in go std lib (I probably won’t fix these…)
  • formatting stops working with no further message or anything

I don’t do anything special and all of this was working pretty well 2 weeks ago. It has become mostly unusable for me 😦

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 2
  • Comments: 50 (21 by maintainers)

Most upvoted comments

$ gopls version
golang.org/x/tools/cmd/gopls v0.1.3-cmd.gopls
    golang.org/x/tools@v0.0.0-20190710165951-554846603d9b h1:I7162G9YBZIueNxlpTOgGoz1oiV1/Kuhqm3ZiGN8lGk=

I continue to experience regular failures of gopls, manifesting as a red squiggle under the package xxx declaration at the top of any file, and a failure to perform any other action, like formatting on save, import organization, click-to-definition, etc. The debug log shows the same messages repeatedly:

[Error - 10:48:48 AM] unable to check package for file:///Users/pbourgon/mod/[redacted]/record.go: failed to cache file file:///Users/pbourgon/mod/[redacted]/get_repos.go: no AST for file:///Users/pbourgon/mod/[redacted]/get_repos.go
[Error - 10:48:48 AM] unable to check package for file:///Users/pbourgon/mod/[redacted]/record.go: failed to cache file file:///Users/pbourgon/mod/[redacted]/get_repos.go: no AST for file:///Users/pbourgon/mod/[redacted]/get_repos.go
[Error - 10:48:48 AM] unable to check package for file:///Users/pbourgon/mod/[redacted]/record.go: failed to cache file file:///Users/pbourgon/mod/[redacted]/get_repos.go: no AST for file:///Users/pbourgon/mod/[redacted]/get_repos.go
[Error - 10:48:48 AM] Request textDocument/documentLink failed.
  Message: no AST for file:///Users/pbourgon/mod/[redacted]/record.go
  Code: 0

Killing gopls and having VS Code automatically restart it fixes the issue for a short while.

I’m not sure which issue is the right place to report these failures anymore.

I’m sorry to hear you are encountering some issues.

Would you be able to supply the logs and other diagnostic information suggested in the troubleshooting section here:

https://github.com/golang/go/wiki/gopls