go: x/tools/gopls: imports and go to definition mostly don't work
Please answer these questions before submitting your issue. Thanks!
What did you do?
add a line that uses a new import. Save. or click go to definition on basically anything
What did you expect to see?
import added or go to definition
What did you see instead?
no import added. Sometimes it’ll format but not import. Most of the time it does neither. or doesn’t go to definition, saying no definition found
Does this issue reproduce with the latest release (go1.12.5)?
yes
System details
go version go1.12.4 darwin/amd64
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/finchnat/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/finchnat"
GOPROXY=""
GORACE=""
GOROOT="/Users/finchnat/sdk/go1.12.4"
GOTMPDIR=""
GOTOOLDIR="/Users/finchnat/sdk/go1.12.4/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/finchnat/mcpp/go.mod"
GOROOT/bin/go version: go version go1.12.4 darwin/amd64
GOROOT/bin/go tool compile -V: compile version go1.12.4
uname -v: Darwin Kernel Version 17.7.0: Wed Apr 24 21:17:24 PDT 2019; root:xnu-4570.71.45~1/RELEASE_X86_64
ProductName: Mac OS X
ProductVersion: 10.13.6
BuildVersion: 17G7024
lldb --version: lldb-1000.11.38.2
Swift-4.2
$ gopls version golang.org/x/tools/cmd/gopls golang.org/x/tools@v0.0.0-20190528151238-d238219cc233 h1:Q8gfsz3A5sYwJeRvYP/nWvLYwU5af6MHYyS8QbI2x88=
"[go]": {
"editor.snippetSuggestions": "none",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
},```
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 13
- Comments: 52 (29 by maintainers)
From my gopls log:
a ton of these:
To get from master you will have to do
go get -u golang.org/x/tools/gopls@master- we began versioninggoplsso that won’t get the latest changes from tip.That seems to have done it (though I have to set it higher than 3000 for it to be reliable). It takes about 4-6 seconds to add an import in our main project. In smaller projects it takes less time. Note that this project is a hair under 80,000 LOC, so it’s not like it’s huge.
I updated gopls and ironically now I’m getting the
no room in queueerror. Maybe I was getting it before and it just wasn’t being printed out, I don’t know.The parse error is weird. Like, the code compiles fine before I add one little line that doesn’t change whether or not it compiles. (that’s what I was just adding
_ = pq.NullTime{}to ensure it’ll compile after I add the line).I had the same problem – failure of go to definition – with a program that I downloaded (okta-hosted-login) and set up as a module not on my GOPATH. It compiled and ran, but I neglected to run
go mod init [myrepository]Once I did that, go to definition started working.Maybe this will help someone else like me, new to go modules, figure this out more quickly than I did!