Closed scrawld closed 4 years ago
The latest version of gopls
is gopls/v0.4.1
, so please update by running :GoInstallBinaries
.
If that doesn't fix the problem, please provide your gopls
logs, which you can collect either through vim-go (let g:go_debug = ["lsp"]
) or through the gopls
command line (gopls -rpc.trace -v check path/to/file.go
).
Run :GoUpdateBinaries
, not :GoInstallBinaries
. The latter will only install binaries that vim-go depends on that are missing. The former will update existing ones and install missing ones. You can update only gopls
with :GoUpdateBinaries gopls
.
I have golang.org/x/tools/gopls 0.4.1. I am having this problem too and just started after I did :GoUpdateBinaries.
@peterfeifanchen: Can you please share the gopls
debug output (you can set let g:go_debug = ["lsp"]
in your Vim configuration)?
`===== sent ===== ===== sent ===== Content-Length: 1696
{"method":"textDocument/didChange","jsonrpc":"2.0","params":{"contentChanges":[{"text":"// +build library\n\n/\nCopyright 2018 The Knative Authors\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n/\n\npackage smoke\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"syscall\"\n\t\"testing\"\n\t\"time\"\n)\n\n// signal sends a UNIX signal to the test process.\nfunc signal(s os.Signal) {\n\tp, := os.FindProcess(os.Getpid())\n\t = p.Signal(s)\n\t// Sleep so test won't finish and signal will be received.\n\ttime.Sleep(999)\n}\n\nfunc TestSucceeds(t testing.T) {\n\t// Always succeed.\n}\n\nfunc TestFails(t testing.T) {\n\tt.Fail()\n}\n\nfunc TestFailsWithFatal(t testing.T) {\n\t// Simulate a zap.Fatal() call.\n\tfmt.Println(\"fatal\tTestFailsWithFatal\tsimple_test.go:999\tFailed with logger.Fatal()\")\n\tsignal(os.Interrupt)\n}\n\nfunc TestFailsWithPanic(t testing.T) {\n\t// Simulate a \"panic\" stack trace.\n\tfmt.Println(\"panic: test timed out after 5m0s\")\n\tsignal(os.Interrupt)\n}\n\nfunc TestFailsWithSigQuit(t *testing.T) {\n\tsignal(syscall.SIGQUIT)\n}\n"}],"textDocument":{"uri":"file:///usr/local/google/home/chenfeif/go/src/knative.dev/test-infra/test/library_test.go","version":4}}} ===== sent ===== Content-Length: 223
{"method":"textDocument/definition","jsonrpc":"2.0","id":4,"params":{"textDocument":{"uri":"file:///usr/local/google/home/chenfeif/go/src/knative.dev/test-infra/test/library_test.go"},"position":{"character":13,"line":32}}} ===== received ===== Content-Length: 319
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"2020/06/15 22:21:24 go/packages.Load\n\tsnapshot=4\n\tdirectory=/usr/local/google/home/chenfeif/go/src/knative.dev/test-infra\n\tquery=[file=/usr/local/google/home/chenfeif/go/src/knative.dev/test-infra/test/library_test.go]\n\tpackages=0\n"}} ===== received ===== Content-Length: 128
{"jsonrpc":"2.0","result":null,"error":{"code":0,"message":"getting file for Identifier: no PackageHandles","data":null},"id":4} ===== received ===== Content-Length: 319
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"2020/06/15 22:21:24 go/packages.Load\n\tsnapshot=4\n\tdirectory=/usr/local/google/home/chenfeif/go/src/knative.dev/test-infra\n\tquery=[file=/usr/local/google/home/chenfeif/go/src/knative.dev/test-infra/test/library_test.go]\n\tpackages=0\n"}}
vim-go: getting file for Identifier: no PackageHandles `
This is what I got while gd'ing.
Thanks! Can you share the output of gopls -rpc.trace -v check path/to/file.go
? Those logs may reveal a bit more. Are you using modules or GOPATH?
2020/06/15 22:33:59 Info:2020/06/15 22:33:59 Build info
golang.org/x/tools/gopls 0.4.1 golang.org/x/tools/gopls@v0.4.1 h1:0e3BPxGV4B3cd0zdMuccwW72SgmHp92lAjOyxX/ScAw= github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= golang.org/x/mod@v0.2.0 h1:KU7oHjnv3XNWfa5COkzUifxZmxp1TyI7ImMXqFxLwvQ= golang.org/x/sync@v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY= golang.org/x/tools@v0.0.0-20200513154647-78b527d18275 h1:e7nYe9s94RHunFJ7b+mmPxiQMOKMVSqYASToWb1EcHs= golang.org/x/xerrors@v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= honnef.co/go/tools@v0.0.1-2020.1.3 h1:sXmLre5bzIR6ypkjXCDI3jHPssRhc8KD/Ome589sc3U= mvdan.cc/xurls/v2@v2.1.0 h1:KaMb5GLhlcSX+e+qhbRJODnUUBvlw01jt4yrjFIHAuA=
go version go1.14.4 linux/amd64
2020/06/15 22:33:59 Info:2020/06/15 22:33:59 go/packages.Load snapshot=0 directory=/usr/local/google/home/chenfeif/go/src/knative.dev/test-infra/test query=[./... builtin] packages=0 2020/06/15 22:33:59 Info:2020/06/15 22:33:59 go env for /usr/local/google/home/chenfeif/go/src/knative.dev/test-infra/test (valid build configuration = true) (build flags: [-modfile=/tmp/go.test.742184675.mod]) GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/usr/local/google/home/chenfeif/.cache/go-build" GOENV="/usr/local/google/home/chenfeif/.config/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/usr/local/google/home/chenfeif/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/lib/google-golang" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/lib/google-golang/pkg/tool/linux_amd64" GCCGO="gccgo" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="/usr/local/google/home/chenfeif/go/src/knative.dev/test-infra/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=/tmp/go-build027282696=/tmp/go-build -gno-record-gcc-switches"
2020/06/15 22:34:00 Info:2020/06/15 22:34:00 go/packages.Load snapshot=1 directory=/usr/local/google/home/chenfeif/go/src/knative.dev/test-infra/test query=[file=/usr/local/google/home/chenfeif/go/src/knative.dev/test-infra/test/library_test.go] packages=0 2020/06/15 22:34:00 Info:2020/06/15 22:34:00 go/packages.Load snapshot=1 directory=/usr/local/google/home/chenfeif/go/src/knative.dev/test-infra/test query=[file=/usr/local/google/home/chenfeif/go/src/knative.dev/test-infra/test/library_test.go] packages=0
It hangs after that. I am not sure what you mean by modules or GOPATH?
Sorry for not clarifying. Using modules refers to the go.mod
file that you have in your project root (/usr/local/google/home/chenfeif/go/src/knative.dev/test-infra/go.mod
).
What is the output of go list -e -json -compiled -test ./...
when you are in the /usr/local/google/home/chenfeif/go/src/knative.dev/test-infra/test
directory? It looks like gopls
is not loading any packages for your project.
Oh yes, I use go.mod files.
chenfeif@chenfeif:~/go/src/knative.dev/test-infra/test$ go list -e -json -compiled -test ./... go: warning: "./..." matched no packages
I do see a list show up when I go up to ~/go/src/knative.dev/test-infra though (a bunch of packages). But there isn't a top-level go file to try out gd'ing. I made a random file there to try it out but gd'ing still didn't work.
I updated gopls to V0.4.1 and golang version to go version go1.13.7 linux/amd64
I set let g:go_debug = ["lsp"] in your Vim configuration.
And then you get the following output
===== sent =====
Content-Length: 549
{"method":"initialize","jsonrpc":"2.0","id":1,"params":{"rootUri":"file:///mnt/e/wsl/work/test","capabilities":{"workspace":{"workspaceFolders":true,"configuration":true,"didChangeConfiguration":{"dynamicRegistration":true}},"textDocument":{"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["source.organizeImports"]}}},"completion":{"completionItem":{"snippetSupport":false}},"hover":{"contentFormat":["plaintext"]}}},"processId":18626,"workspaceFolders":[{"uri":"file:///mnt/e/wsl/work/test","name":"/mnt/e/wsl/work/test"}]}}
===== stderr =====
2020/06/16 10:17:51 debug server listening on port 51379
===== received =====
Content-Length: 1901
{"jsonrpc":"2.0","result":{"capabilities":{"textDocumentSync":{"change":2,"openClose":true,"save":{}},"completionProvider":{"triggerCharacters":["."]},"hoverProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",","]},"definitionProvider":true,"typeDefinitionProvider":true,"implementationProvider":true,"referencesProvider":true,"documentHighlightProvider":true,"documentSymbolProvider":true,"codeActionProvider":{"codeActionKinds":["quickfix","source.fixAll","source.organizeImports"]},"codeLensProvider":{},"documentLinkProvider":{},"workspaceSymbolProvider":true,"documentFormattingProvider":true,"documentOnTypeFormattingProvider":{"firstTriggerCharacter":""},"renameProvider":true,"foldingRangeProvider":true,"executeCommandProvider":{"commands":["tidy","upgrade.dependency","generate"]},"workspace":{"workspaceFolders":{"supported":true,"changeNotifications":"workspace/didChangeWorkspaceFolders"}}},"serverInfo":{"name":"gopls","version":"Build info\n----------\ngolang.org/x/tools/gopls 0.4.1\n golang.org/x/tools/gopls@v0.4.1 h1:0e3BPxGV4B3cd0zdMuccwW72SgmHp92lAjOyxX/ScAw=\n github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=\n github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=\n golang.org/x/mod@v0.2.0 h1:KU7oHjnv3XNWfa5COkzUifxZmxp1TyI7ImMXqFxLwvQ=\n golang.org/x/sync@v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY=\n golang.org/x/tools@v0.0.0-20200513154647-78b527d18275 h1:e7nYe9s94RHunFJ7b+mmPxiQMOKMVSqYASToWb1EcHs=\n golang.org/x/xerrors@v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=\n honnef.co/go/tools@v0.0.1-2020.1.3 h1:sXmLre5bzIR6ypkjXCDI3jHPssRhc8KD/Ome589sc3U=\n mvdan.cc/xurls/v2@v2.1.0 h1:KaMb5GLhlcSX+e+qhbRJODnUUBvlw01jt4yrjFIHAuA=\n\nGo info\n-------\ngo version go1.13.7 linux/amd64\n\n"}},"id":1}
===== sent =====
Content-Length: 52
{"method":"initialized","jsonrpc":"2.0","params":{}}
===== sent =====
Content-Length: 292
{"method":"textDocument/didOpen","jsonrpc":"2.0","params":{"textDocument":{"uri":"file:///mnt/e/wsl/work/test/src/test-se/main.go","version":1,"languageId":"go","text":"package main\n\nimport (\n\t\"fmt\"\n\t\"testutils\"\n)\n\nfunc main() {\n\tn := testutils.Add()\n\tfmt.Println(n)\n}\n"}}}
===== received =====
Content-Length: 268
{"jsonrpc":"2.0","method":"client/registerCapability","params":{"registrations":[{"id":"workspace/didChangeConfiguration","method":"workspace/didChangeConfiguration"},{"id":"workspace/didChangeWorkspaceFolders","method":"workspace/didChangeWorkspaceFolders"}]},"id":1}
===== sent =====
Content-Length: 38
{"id":1,"jsonrpc":"2.0","result":null}
===== received =====
Content-Length: 223
{"jsonrpc":"2.0","method":"workspace/configuration","params":{"items":[{"scopeUri":"file:///mnt/e/wsl/work/test","section":"gopls"},{"scopeUri":"file:///mnt/e/wsl/work/test","section":"gopls-/mnt/e/wsl/work/test"}]},"id":2}
===== sent =====
Content-Length: 121
{"id":2,"jsonrpc":"2.0","result":[{"buildFlags":[],"hoverKind":"Structured"},{"buildFlags":[],"hoverKind":"Structured"}]}
===== received =====
Content-Length: 1034
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"2020/06/16 10:17:52 Build info\n----------\ngolang.org/x/tools/gopls 0.4.1\n golang.org/x/tools/gopls@v0.4.1 h1:0e3BPxGV4B3cd0zdMuccwW72SgmHp92lAjOyxX/ScAw=\n github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=\n github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=\n golang.org/x/mod@v0.2.0 h1:KU7oHjnv3XNWfa5COkzUifxZmxp1TyI7ImMXqFxLwvQ=\n golang.org/x/sync@v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY=\n golang.org/x/tools@v0.0.0-20200513154647-78b527d18275 h1:e7nYe9s94RHunFJ7b+mmPxiQMOKMVSqYASToWb1EcHs=\n golang.org/x/xerrors@v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=\n honnef.co/go/tools@v0.0.1-2020.1.3 h1:sXmLre5bzIR6ypkjXCDI3jHPssRhc8KD/Ome589sc3U=\n mvdan.cc/xurls/v2@v2.1.0 h1:KaMb5GLhlcSX+e+qhbRJODnUUBvlw01jt4yrjFIHAuA=\n\nGo info\n-------\ngo version go1.13.7 linux/amd64\n\n\n"}}
===== received =====
Content-Length: 201
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"2020/06/16 10:17:52 go/packages.Load\n\tsnapshot=0\n\tdirectory=/mnt/e/wsl/work/test\n\tquery=[./ builtin]\n\tpackages=2\n"}}
===== received =====
Content-Length: 1388
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"2020/06/16 10:17:52 go env for /mnt/e/wsl/work/test\n(valid build configuration = false)\n(build flags: [])\nGO111MODULE=\"auto\"\nGOARCH=\"amd64\"\nGOBIN=\"/home/ziyang/etc/go/bin\"\nGOCACHE=\"/home/ziyang/.cache/go-build\"\nGOENV=\"/home/ziyang/.config/go/env\"\nGOEXE=\"\"\nGOFLAGS=\"\"\nGOHOSTARCH=\"amd64\"\nGOHOSTOS=\"linux\"\nGONOPROXY=\"\"\nGONOSUMDB=\"\"\nGOOS=\"linux\"\nGOPATH=\"/home/ziyang/etc/go:/home/ziyang/work/cms_oprate:/home/ziyang/work/cms_risk:/home/ziyang/work/coinutils:/home/ziyang/work/inquiry:/home/ziyang/work/notify_server:/home/ziyang/work/proxy_server:/home/ziyang/work/script_projects:/home/ziyang/work/test:/home/ziyang/work/user:/home/ziyang/work/walletbch:/home/ziyang/work/walletbsv:/home/ziyang/work/walletdoge:/home/ziyang/work/walletltc\"\nGOPRIVATE=\"\"\nGOPROXY=\"https://goproxy.io\"\nGOROOT=\"/usr/local/go\"\nGOSUMDB=\"sum.golang.org\"\nGOTMPDIR=\"\"\nGOTOOLDIR=\"/usr/local/go/pkg/tool/linux_amd64\"\nGCCGO=\"gccgo\"\nAR=\"ar\"\nCC=\"gcc\"\nCXX=\"g++\"\nCGO_ENABLED=\"1\"\nGOMOD=\"\"\nCGO_CFLAGS=\"-g -O2\"\nCGO_CPPFLAGS=\"\"\nCGO_CXXFLAGS=\"-g -O2\"\nCGO_FFLAGS=\"-g -O2\"\nCGO_LDFLAGS=\"-g -O2\"\nPKG_CONFIG=\"pkg-config\"\nGOGCCFLAGS=\"-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build242781473=/tmp/go-build -gno-record-gcc-switches\"\n\n"}}
===== received =====
Content-Length: 193
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"2020/06/16 10:17:52 go/packages.Load\n\tsnapshot=0\n\tdirectory=/mnt/e/wsl/work/test\n\tquery=[./]\n\tpackages=1\n"}}
===== received =====
Content-Length: 193
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"2020/06/16 10:17:52 go/packages.Load\n\tsnapshot=1\n\tdirectory=/mnt/e/wsl/work/test\n\tquery=[./]\n\tpackages=1\n"}}
===== received =====
Content-Length: 236
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"2020/06/16 10:17:53 go/packages.Load\n\tsnapshot=1\n\tdirectory=/mnt/e/wsl/work/test\n\tquery=[file=/mnt/e/wsl/work/test/src/test-se/main.go]\n\tpackages=1\n"}}
===== received =====
Content-Length: 213
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"2020/06/16 10:17:53 go/packages.Load\n\tsnapshot=1\n\tpackage_path=\"test-se\"\n\tfiles=[/home/ziyang/work/test/src/test-se/main.go]\n"}}
===== sent =====
Content-Length: 297
{"method":"textDocument/didChange","jsonrpc":"2.0","params":{"contentChanges":[{"text":"package main\n\nimport (\n\t\"fmt\"\n\t\"testutils\"\n)\n\nfunc main() {\n\tn := testutils.Add()\n\tfmt.Println(n)\n}\n"}],"textDocument":{"uri":"file:///mnt/e/wsl/work/test/src/test-se/main.go","version":2}}}
===== sent =====
Content-Length: 179
{"method":"textDocument/definition","jsonrpc":"2.0","id":2,"params":{"textDocument":{"uri":"file:///mnt/e/wsl/work/test/src/test-se/main.go"},"position":{"character":6,"line":9}}}
===== received =====
Content-Length: 193
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"2020/06/16 10:17:53 go/packages.Load\n\tsnapshot=2\n\tdirectory=/mnt/e/wsl/work/test\n\tquery=[./]\n\tpackages=1\n"}}
===== received =====
Content-Length: 128
{"jsonrpc":"2.0","result":null,"error":{"code":0,"message":"getting file for Identifier: no PackageHandles","data":null},"id":2}
===== received =====
Content-Length: 213
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"2020/06/16 10:17:53 go/packages.Load\n\tsnapshot=2\n\tpackage_path=\"test-se\"\n\tfiles=[/home/ziyang/work/test/src/test-se/main.go]\n"}}
===== received =====
Content-Length: 236
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"2020/06/16 10:17:53 go/packages.Load\n\tsnapshot=2\n\tdirectory=/mnt/e/wsl/work/test\n\tquery=[file=/mnt/e/wsl/work/test/src/test-se/main.go]\n\tpackages=1\n"}}
===== received =====
Content-Length: 213
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"2020/06/16 10:17:53 go/packages.Load\n\tsnapshot=2\n\tpackage_path=\"test-se\"\n\tfiles=[/home/ziyang/work/test/src/test-se/main.go]\n"}}
===== received =====
Content-Length: 236
{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"2020/06/16 10:17:53 go/packages.Load\n\tsnapshot=2\n\tdirectory=/mnt/e/wsl/work/test\n\tquery=[file=/mnt/e/wsl/work/test/src/test-se/main.go]\n\tpackages=1\n"}}
@peterfeifanchen:
chenfeif@chenfeif:~/go/src/knative.dev/test-infra/test$ go list -e -json -compiled -test ./... go: warning: "./..." matched no packages
It sounds like something is misconfigured in this directory. Are you able to share the contents of that directory, or what kinds of files you have there?
@scrawld:
It looks like gopls
is not finding a valid build configuration for your project. Are you using modules or GOPATH? My guess is that you are using GOPATH, but your workspace root is open above your GOPATH. gopls
doesn't load workspaces outside of the GOPATH
, so I would suggest opening the /mnt/e/wsl/work/test/src/test-se/
directory as your workspace root.
I used GOPATH.
/mnt/e/wsl/work/test/src/test-se/
will have the same problem for the working root.
Can you provide any logs fro that case? An alternative to capturing Vim logs is to run gopls -rpc.trace -v check path/to/file.go
. Make sure to run the command from the workspace root directory.
ziyang@Dev-25:~/work/test/src/test-se$ gopls -rpc.trace -v check ~/work/test/src/test-se/main.go
golang.org/x/tools/gopls 0.4.1 golang.org/x/tools/gopls@v0.4.1 h1:0e3BPxGV4B3cd0zdMuccwW72SgmHp92lAjOyxX/ScAw= github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= golang.org/x/mod@v0.2.0 h1:KU7oHjnv3XNWfa5COkzUifxZmxp1TyI7ImMXqFxLwvQ= golang.org/x/sync@v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY= golang.org/x/tools@v0.0.0-20200513154647-78b527d18275 h1:e7nYe9s94RHunFJ7b+mmPxiQMOKMVSqYASToWb1EcHs= golang.org/x/xerrors@v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= honnef.co/go/tools@v0.0.1-2020.1.3 h1:sXmLre5bzIR6ypkjXCDI3jHPssRhc8KD/Ome589sc3U= mvdan.cc/xurls/v2@v2.1.0 h1:KaMb5GLhlcSX+e+qhbRJODnUUBvlw01jt4yrjFIHAuA=
go version go1.13.7 linux/amd64
2020/06/16 14:55:15 Info:2020/06/16 14:55:15 go env for /home/ziyang/work/test/src/test-se (valid build configuration = true) (build flags: []) GO111MODULE="auto" GOARCH="amd64" GOBIN="/home/ziyang/etc/go/bin" GOCACHE="/home/ziyang/.cache/go-build" GOENV="/home/ziyang/.config/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/home/ziyang/etc/go:/home/ziyang/work/cms_oprate:/home/ziyang/work/cms_risk:/home/ziyang/work/coinutils:/home/ziyang/work/inquiry:/home/ziyang/work/notify_server:/home/ziyang/work/proxy_server:/home/ziyang/work/script_projects:/home/ziyang/work/test:/home/ziyang/work/user:/home/ziyang/work/walletbch:/home/ziyang/work/walletbsv:/home/ziyang/work/walletdoge:/home/ziyang/work/walletltc" GOPRIVATE="" GOPROXY="https://goproxy.io" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" GCCGO="gccgo" AR="ar" 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-build656504483=/tmp/go-build -gno-record-gcc-switches"
2020/06/16 14:55:16 Info:2020/06/16 14:55:16 go/packages.Load snapshot=0 directory=/home/ziyang/work/test/src/test-se query=[./... builtin] packages=2
I get this error for every package under my $GOPATH. I was just using this directory as an example.
@scrawld are any of the directories in your $GOMOD value symlinks?
the workaround is setting GOPACKAGESDRIVER=off. That has worked for everyone here at my company.
Ah @peterfeifanchen, I didn't realize that you're a Googler. This is an issue that I'd be happy to follow up with you internally.
Is that so @bhcleek
ziyang@Dev-25:~$ echo $GOMOD
ziyang@Dev-25:~$
I tried to add an environment variable GOPACKAGESDRIVER=off
.
It doesn't seem to be working.
Is there a temporary solution.
I get this error for every package under my $GOPATH.
@scrawld the GOPACKAGESDRIVER
is only relevant to googlers.
For your $GOMOD, you'll need to run go env GOMOD
in the directory of your package that's having a problem.
Is anything in your $GOPATH a symlink?
There's no problem with GOMOD. All projects in the GOPATH directory have this problem. The $GOPATH interval is:, I think I configured $GOPATH with no problem
ziyang@Dev-25:~/tmp/test$ echo $GOPATH;
/home/ziyang/etc/go:/home/ziyang/work/cms_oprate:/home/ziyang/work/cms_risk:/home/ziyang/work/coinutils:/home/ziyang/work/inquiry:/home/ziyang/work/notify_server:/home/ziyang/work/proxy_server:/home/ziyang/work/script_projects:/home/ziyang/work/test:/home/ziyang/work/user:/home/ziyang/work/walletbch:/home/ziyang/work/walletbsv:/home/ziyang/work/walletdoge:/home/ziyang/work/walletltc
There's no problem with GOMOD.
Can you clarify what you mean by this? How do you know there's no problem? It's difficult to help you if you don't answer the questions asked: are there any symlinks in your the value returned by go env GOMOD
when run in a directory of one of the packages that's having a problem?
The $GOPATH interval is:,
I'm not sure what this means. Can you clarify?
Running go env GOMOD
in one of the problematic packages returns an empty one
The $GOPATH interval is:,
I just want to express the interval character of $GOPATH
@scrawld: The output of the gopls check
command looked correct. Can you please share the Vim gopls
logs when you start Vim in the /home/ziyang/work/test/src/test-se
directory?
Are these the VIM logs you are referring to
Messages maintainer: Bram Moolenaar <Bram@vim.org>
"main.go" 9L, 69C
vim-go: initializing gopls
vim-go: initialized gopls
vim-go: [definition] FAIL
vim-go: getting file for Identifier: no PackageHandles
Press ENTER or type command to continue
@scrawld I think that @stamblerre is looking for the logs you provided in https://github.com/fatih/vim-go/issues/2924#issuecomment-644492541
@scrawld it looks like your working directory and files are in /mnt/e/wsl/work/test
, but that is not in your GOPATH.
@stamblerre I think that's often been the root cause for this kind of problem. Can you confirm or deny?
Yeah, it's typically more of problem for modules, but it is a common cause. We hope to have a fix for it by v0.6.0.
I'm hitting this now - I thought part of the goal of modules was to remove the dependency on GOPATH?
@thockin I think at least part of the issue here is that there isn't a module and the GOPATH seems to be symlinked.
I am now hitting this with or without GOPATH now.
$ echo $GOPATH
/tmp/g/
$ pwd
/tmp/g/src/github.com/thockin/hack
$ ls
proxy.go
$ cat proxy.go
package main
import (
"math/rand"
"os"
"time"
)
func main() {
rand.Seed(time.Now().UnixNano())
os.Exit(1)
}
$ gopls -rpc.trace -v check proxy.go
2020/06/17 11:52:10 Info:2020/06/17 11:52:10 Build info
----------
golang.org/x/tools/gopls 0.4.1
golang.org/x/tools/gopls@v0.4.1 h1:0e3BPxGV4B3cd0zdMuccwW72SgmHp92lAjOyxX/ScAw=
github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
golang.org/x/mod@v0.2.0 h1:KU7oHjnv3XNWfa5COkzUifxZmxp1TyI7ImMXqFxLwvQ=
golang.org/x/sync@v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY=
golang.org/x/tools@v0.0.0-20200513154647-78b527d18275 h1:e7nYe9s94RHunFJ7b+mmPxiQMOKMVSqYASToWb1EcHs=
golang.org/x/xerrors@v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
honnef.co/go/tools@v0.0.1-2020.1.3 h1:sXmLre5bzIR6ypkjXCDI3jHPssRhc8KD/Ome589sc3U=
mvdan.cc/xurls/v2@v2.1.0 h1:KaMb5GLhlcSX+e+qhbRJODnUUBvlw01jt4yrjFIHAuA=
Go info
-------
go version go1.14.4 linux/amd64
2020/06/17 11:52:10 Info:2020/06/17 11:52:10 go/packages.Load
snapshot=0
directory=/tmp/g/src/github.com/thockin/hack
query=[./... builtin]
packages=0
2020/06/17 11:52:10 Info:2020/06/17 11:52:10 go env for /tmp/g/src/github.com/thockin/hack
(valid build configuration = true)
(build flags: [])
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/usr/local/google/home/thockin/.cache/go-build"
GOENV="/usr/local/google/home/thockin/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/tmp/g/"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/google-golang"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/google-golang/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
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=/tmp/go-build415845681=/tmp/go-build -gno-record-gcc-switches"
2020/06/17 11:52:10 Info:2020/06/17 11:52:10 go/packages.Load
snapshot=1
directory=/tmp/g/src/github.com/thockin/hack
query=[file=/tmp/g/src/github.com/thockin/hack/proxy.go]
packages=0
^C
When I gd
on a symbol like time.Now
I get "vim-go: getting file for Identifier: no PackageHandles"
I'm not sure how GOPACKAGESDRIVER
may influence gopls' behaviors on a googler's machine and when GOPACKAGESDRIVER
should be configured for you. @stamblerre can you provide some basic guidance if GOPACKAGESDRIVER
is relevant to what @thockin is seeing?
@thockin as a workaround until this gets sorted, you can use godef
or guru
instead of gopls
by setting g:go_def_mode
(see :help g:go_def_mode
).
Sorry, no help for g:go_def_mode
setting it to 'godef' fixes gd
@thockin: Setting GOPACKAGESDRIVER=off
in your environment should definitely fix it, but I believe that the bug should already be resolved. This is a Google-specific issue that I'd be happy to continue discussing with you internally.
?!?!? That does seem to work. Why the heck do I have a broken-by-default install?
As I mentioned above, it's an internal issue caused by a bad tool release within Google, so it's not caused by gopls
itself. Happy to follow-up internally and ping you the bug number, if you're interested.
@scrawld it looks like your working directory and files are in
/mnt/e/wsl/work/test
, but that is not in your GOPATH.
Thank you very much for the reason that I configured the soft connection in $GOPATH. I changed $GOPATH to the absolute path file corresponding to the soft connection. The problem has now been solved.
$GOPATH configured as a soft connection path can go build
successfully but not with gd
I'm going to leave this open, while I investigate a possibility for maintaining symlinked paths in vim-go.
I thought I might have realized a way to maintain the symlinked path within Vim, but it's didn't pan out.
Go doesn't fully support symlinks and neither does vim-go; you'll need to use a real paths for your GOPATH instead of symlinks.
This issue has been discussed multiple times in vim-go's history and in Go's history. Here's Rob Pike's answer: https://github.com/golang/go/issues/15507#issuecomment-241581036
I hate that symlinks answer, and it makes me sad that "it's too hard, lets just not try" is the best we can do.
I understand. Without speaking to the value of Rob's answer, there's also a real concern in Vim. I've never been able to find a way to get the absolute, unresolved path of a file that's below a directory that is a symlink, which throws a wrench in providing file URLs to gopls.
What did you expect to happen?
What happened instead?
Configuration (MUST fill this out): https://github.com/scrawld/vimrc/blob/master/.vimrc
vim-go version: lastest
vimrc
you used to reproduce: Yes, I haveVim version (first three lines from
:version
):Go version (
go version
):Go environment
gopls version
gopls version
Output: