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: language features fail for first file opened in module's workspace #37276

Closed
nickhstr opened this issue Feb 18, 2020 · 6 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@nickhstr
Copy link

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

go version go1.13.7 darwin/amd64
golang.org/x/tools/gopls v0.3.2
    golang.org/x/tools/gopls@v0.3.2 h1:eP1aj1AvT6ynElQH6KP0mmOT2gnWa1gYclHL4wGUbMo=

Does this issue reproduce with the latest release?

Yes

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

go env Output
GOARCH="amd64"
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"

What did you do?

Using either VS Code with the Go extension, or Sublime with the LSP extension, I opened a directory containing a Go module, and opened one of the module's Go files. This file had none of the expected language server features working in any capacity.

Subsequently opened Go files are unaffected by this issue. Only the first file is affected, and remains affected no matter if the file is closed and opened at a later time.

This issue is not specific to any file, nor any Go module; it has affected every first file opened during a text editing session for every Go module's workspace.

Downgrading gopls to 0.3.0 resolves the issue.

What did you expect to see?

Language server features working for the first opened Go file.

What did you see instead?

Language server features not working for the first opened Go file.

@gopherbot gopherbot added this to the Unreleased milestone Feb 18, 2020
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Feb 18, 2020
@gopherbot
Copy link

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.

@stamblerre
Copy link
Contributor

Can you share the gopls logs from when this happens? https://github.com/golang/tools/blob/master/gopls/doc/troubleshooting.md#capturing-logs explains how to do this.

@stamblerre stamblerre modified the milestones: Unreleased, gopls/v0.4.0 Feb 18, 2020
@nickhstr
Copy link
Author

Oddly enough, I now cannot reproduce the issue in VS Code using 0.3.2; however, it is still reproducible
in Sublime with the LSP package (Sublime 3211, LSP v0.9.4). This indicates to me that this is possibly just an editor integration issue.
Using https://github.com/nickhstr/go-web-service for debugging, here is what I see in the Sublime LSP package's console, after opening a file and hovering over something:

:: --> gopls initialize(1)
:: <-- gopls 1
:: --> gopls initialized
:: --> gopls textDocument/didOpen
gopls: 2020/02/18 14:41:56 Build info
----------
golang.org/x/tools/gopls v0.3.2
    golang.org/x/tools/gopls@v0.3.2 h1:eP1aj1AvT6ynElQH6KP0mmOT2gnWa1gYclHL4wGUbMo=
    github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
    github.com/sergi/go-diff@v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
    golang.org/x/mod@v0.1.1-0.20191105210325-c90efee705ee h1:WG0RUwxtNT4qqaXX3DPA8zHFNm/D9xaBpxzHt1WcA/E=
    golang.org/x/sync@v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
    golang.org/x/tools@v0.0.0-20200212213342-7a21e308cf6c h1:D2X+P0Z6ychko7xn2jvd38yxQfdU0eksO4AHfd8AWFI=
    golang.org/x/xerrors@v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA=
    honnef.co/go/tools@v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM=
    mvdan.cc/xurls/v2@v2.1.0 h1:KaMb5GLhlcSX+e+qhbRJODnUUBvlw01jt4yrjFIHAuA=

Go info
-------
go version go1.13.7 darwin/amd64

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/xxxxx/Library/Caches/go-build"
GOENV="/Users/xxxxx/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/xxxxx/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.13.7/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.13.7/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/xxxxx/nickhstr/go-web-service/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=/var/folders/2f/cmt9mjq11d1bplj9v1qzwmw40000gn/T/go-build974075391=/tmp/go-build -gno-record-gcc-switches -fno-common"

:: <-- gopls workspace/configuration(1)
:: --> gopls 1
gopls: 2020/02/18 14:41:57 go/packages.Load
    snapshot = 0
    query = [./... builtin]
    packages = 3
gopls: 2020/02/18 14:41:57 go/packages.Load
    snapshot = 1
    query = [file=/Users/xxxxx/nickhstr/go-web-service/main.go]
    packages = 1
gopls: 2020/02/18 14:41:57 go/packages.Load
    snapshot = 1
    package = github.com/nickhstr/go-web-service
    files = [/Users/xxxxx/nickhstr/go-web-service/main.go]
gopls: 2020/02/18 14:41:57 go/packages.Load
    snapshot = 0
    query = [file=/Users/xxxxx/nickhstr/go-web-service/main.go]
    packages = 1
gopls: 2020/02/18 14:41:58 go/packages.Load
    snapshot = 0
    package = github.com/nickhstr/go-web-service
    files = [/Users/xxxxx/nickhstr/go-web-service/main.go]
:: --> gopls textDocument/hover(2)
gopls: 2020/02/18 14:42:06 go/packages.Load
    snapshot = 1
    package = github.com/nickhstr/go-web-service
    files = [/Users/xxxxx/nickhstr/go-web-service/main.go]
gopls: 2020/02/18 14:42:06 go/packages.Load
    snapshot = 1
    query = [file=/Users/xxxxx/nickhstr/go-web-service/main.go]
    packages = 1
:: <-- gopls 2

@stamblerre
Copy link
Contributor

This does sound like a Sublime-specific issue to me, so I would suggest opening an issue on that repository. My immediate guess, based on a quick glance at this log, is that the issue is that the didOpen request comes in before the workspace/configuration response. gopls will block on receiving that response, so it's possible something is going wrong with the first file as a result.

@nickhstr
Copy link
Author

Great, will do. Thanks for taking a look!

@stamblerre
Copy link
Contributor

Thanks for filing the Sublime issue! I'll close this issue, but please feel free to re-open if the bug is determined to be in gopls.

@golang golang locked and limited conversation to collaborators Feb 17, 2021
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. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants