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: go to definition doesn't work in VSCode #32608

Closed
jbrodriguez opened this issue Jun 13, 2019 · 6 comments
Closed

x/tools/gopls: go to definition doesn't work in VSCode #32608

jbrodriguez opened this issue Jun 13, 2019 · 6 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls.
Milestone

Comments

@jbrodriguez
Copy link

Please answer these questions before submitting your issue. Thanks!

What did you do?

click go to definition on basically anything

What did you expect to see?

go to definition

What did you see instead?

doesn't go to definition, saying no definition found

Does this issue reproduce with the latest release (go1.12.6)?

yes

System details

⟩ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/johndoe/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Volumes/Home/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.12.6/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.12.6/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/w9/7tlszcbs3msddknxvpp64gwc0000gn/T/go-build991404057=/tmp/go-build -gno-record-gcc-switches -fno-common"
⟩ gopls version
version v0.1.0-cmd.gopls, built in $GOPATH mode

vscode settings

	"go.lintTool": "golangci-lint",
	"go.lintFlags": [
		"--enable-all",
		"-D",
		"maligned",
		"-D",
		"gochecknoglobals",
		"-D",
		"prealloc",
		"-D",
		"gosec",
		"-D",
		"lll",
		"-D",
		"gofmt"
	],
	"go.liveErrors": {
		"enabled": true,
		"delay": 250
	},
	"go.alternateTools": {
		"go-langserver": "gopls"
	},
	"go.useLanguageServer": true,
	"go.languageServerExperimentalFeatures": {
		"format": true,
		"autoComplete": true
	},
	"[go]": {
		"editor.formatOnSave": true,
		"editor.codeActionsOnSave": {
			"source.organizeImports": true
		},
		"editor.codeActionsOnSaveTimeout": 30000
	},
	"go.buildOnSave": "package",
	"go.lintOnSave": "package",
	"go.docsTool": "gogetdoc",

This happens on repo github.com/jbrodriguez/unbalance, that uses go modules

@ThisEndUp
Copy link

Related:
Although this program (the "trivial example" in the GoDoc for Package Template) does work in the Go Playground,
https://play.golang.org/p/ZS0HyvHG6-1
it does not work on my PC running go version 1.12.
Both go build main.go and go run main.go fail with

main.go:4:2: cannot find package "text/template" in any of:
        C:\Go\src\text\template (from $GOROOT)
        D:\xxx\Go\src\text\template (from $GOPATH)

@stamblerre
Copy link
Contributor

@jbrodriguez: Can you provide your gopls log? Add

"go.languageServerFlags": [
        "-rpc.trace",
]

to your VSCode settings, and then run an example case. You can find the debug logs by going to View: Debug Console -> Output -> Tasks -> gopls.

@ThisEndUp: I do not believe your issue is related - it seems like a case of a broken Go installation to me. Please file a separate issue so that you can get assistance.

@FiloSottile FiloSottile added the gopls Issues related to the Go language server, gopls. label Jun 13, 2019
@FiloSottile FiloSottile changed the title Go to definition doesn't work in VSCode x/tools/gopls: go to definition doesn't work in VSCode Jun 13, 2019
@gopherbot gopherbot added this to the Unreleased milestone Jun 13, 2019
@ThisEndUp
Copy link

Thanks @jbrodriguez. The program did run on my PC, so the go installation was fine, but then it stopped. I can't figure out what broke the installation from one day to the next, but I repaired it by downloading go-master.zip from github and extracting the directory text into $GOROOTC/src .

@jbrodriguez
Copy link
Author

@stamblerre, sure here's the log

[Trace - 6:39:24 AM] Sending request 'initialize - (0)'.
Params: {"processId":54694,"rootPath":"/Volumes/Home/code/unbalance","rootUri":"file:///Volumes/Home/code/unbalance","capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true},"didChangeConfiguration":{"dynamicRegistration":true},"didChangeWatchedFiles":{"dynamicRegistration":true},"symbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}},"executeCommand":{"dynamicRegistration":true},"configuration":true,"workspaceFolders":true},"textDocument":{"publishDiagnostics":{"relatedInformation":true},"synchronization":{"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":true,"contextSupport":true,"completionItem":{"snippetSupport":true,"commitCharactersSupport":true,"documentationFormat":["markdown","plaintext"],"deprecatedSupport":true,"preselectSupport":true},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]}},"hover":{"dynamicRegistration":true,"contentFormat":["markdown","plaintext"]},"signatureHelp":{"dynamicRegistration":true,"signatureInformation":{"documentationFormat":["markdown","plaintext"]}},"definition":{"dynamicRegistration":true},"references":{"dynamicRegistration":true},"documentHighlight":{"dynamicRegistration":true},"documentSymbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"hierarchicalDocumentSymbolSupport":true},"codeAction":{"dynamicRegistration":true,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"codeLens":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true},"documentLink":{"dynamicRegistration":true},"typeDefinition":{"dynamicRegistration":true},"implementation":{"dynamicRegistration":true},"colorProvider":{"dynamicRegistration":true},"foldingRange":{"dynamicRegistration":true,"rangeLimit":5000,"lineFoldingOnly":true}}},"initializationOptions":{"funcSnippetEnabled":false,"gocodeCompletionEnabled":true},"trace":"off","workspaceFolders":[{"uri":"file:///Volumes/Home/code/unbalance","name":"unbalance"}]}


[Trace - 6:39:24 AM] Received response 'initialize - (0)' in 32ms.
Params: {"capabilities":{"textDocumentSync":{"openClose":true,"change":1},"hoverProvider":true,"completionProvider":{"triggerCharacters":["."]},"signatureHelpProvider":{"triggerCharacters":["(",","]},"definitionProvider":true,"referencesProvider":true,"documentHighlightProvider":true,"documentSymbolProvider":true,"codeActionProvider":true,"documentFormattingProvider":true,"documentLinkProvider":{},"typeDefinitionProvider":true,"workspace":{"workspaceFolders":{"supported":true,"changeNotifications":"workspace/didChangeWorkspaceFolders"}}},"custom":null}


[Trace - 6:39:24 AM] Sending notification 'initialized'.
Params: {}


[Trace - 6:39:24 AM] Received request 'client/registerCapability - (1)'.
Params: {"registrations":[{"id":"workspace/didChangeConfiguration","method":"workspace/didChangeConfiguration"},{"id":"workspace/didChangeWorkspaceFolders","method":"workspace/didChangeWorkspaceFolders"}]}


[Trace - 6:39:24 AM] Sending notification 'textDocument/didOpen'.
Params: {"textDocument":{"uri":"file:///Volumes/Home/code/unbalance/server/unbalance.go","languageId":"go","version":1,"text":"package main\n\nimport (\n\t\"log\"\n\t\"os\"\n\n\t\"unbalance/app\"\n)\n\n// Version -\nvar version string\nvar plgver string\n\nfunc main() {\n\tapp := app.App{}\n\n\tsettings, err := app.Setup(plgver + \" (\" + version + \")\")\n\tif err != nil {\n\t\tlog.Printf(\"Unable to start the app: %s\", err)\n\t\tos.Exit(1)\n\t}\n\n\tapp.Run(settings)\n}\n"}}


[Trace - 6:39:24 AM] Sending response 'client/registerCapability - (1)' in 107ms.
Params: {}


[Trace - 6:39:24 AM] Received request 'workspace/configuration - (2)'.
Params: {"items":[{"scopeUri":"file:///Volumes/Home/code/unbalance","section":"gopls"}]}


[Trace - 6:39:24 AM] Sending response 'workspace/configuration - (2)' in 9ms.
Params: [null]


[Trace - 6:39:25 AM] Sending request 'textDocument/documentSymbol - (1)'.
Params: {"textDocument":{"uri":"file:///Volumes/Home/code/unbalance/server/unbalance.go"}}


[Trace - 6:39:25 AM] Sending request 'textDocument/codeAction - (2)'.
Params: {"textDocument":{"uri":"file:///Volumes/Home/code/unbalance/server/unbalance.go"},"range":{"start":{"line":16,"character":24},"end":{"line":16,"character":24}},"context":{"diagnostics":[]}}


[Trace - 6:39:25 AM] Sending request 'textDocument/documentLink - (3)'.
Params: {"textDocument":{"uri":"file:///Volumes/Home/code/unbalance/server/unbalance.go"}}


[Trace - 6:39:25 AM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"Build info\n----------\nversion v0.1.0-cmd.gopls, built in $GOPATH mode\n\nGo info\n-------\ngo version go1.12.6 darwin/amd64\n\nGOARCH=\"amd64\"\nGOBIN=\"\"\nGOCACHE=\"/Users/johndoe/Library/Caches/go-build\"\nGOEXE=\"\"\nGOFLAGS=\"\"\nGOHOSTARCH=\"amd64\"\nGOHOSTOS=\"darwin\"\nGOOS=\"darwin\"\nGOPATH=\"/Volumes/Home/go\"\nGOPROXY=\"\"\nGORACE=\"\"\nGOROOT=\"/usr/local/Cellar/go/1.12.6/libexec\"\nGOTMPDIR=\"\"\nGOTOOLDIR=\"/usr/local/Cellar/go/1.12.6/libexec/pkg/tool/darwin_amd64\"\nGCCGO=\"gccgo\"\nCC=\"clang\"\nCXX=\"clang++\"\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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/w9/7tlszcbs3msddknxvpp64gwc0000gn/T/go-build867739287=/tmp/go-build -gno-record-gcc-switches -fno-common\"\n"}


[Info  - 6:39:25 AM] Build info
----------
version v0.1.0-cmd.gopls, built in $GOPATH mode

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

GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/johndoe/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Volumes/Home/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.12.6/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.12.6/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/w9/7tlszcbs3msddknxvpp64gwc0000gn/T/go-build867739287=/tmp/go-build -gno-record-gcc-switches -fno-common"

[Trace - 6:39:26 AM] Received notification 'window/logMessage'.
Params: {"type":1,"message":"unable to check package for file:///Volumes/Home/code/unbalance/server/unbalance.go: no packages found for /Volumes/Home/code/unbalance/server/unbalance.go"}


[Error - 6:39:26 AM] unable to check package for file:///Volumes/Home/code/unbalance/server/unbalance.go: no packages found for /Volumes/Home/code/unbalance/server/unbalance.go
[Trace - 6:39:26 AM] Received notification 'window/logMessage'.
Params: {"type":1,"message":"unable to check package for file:///Volumes/Home/code/unbalance/server/unbalance.go: no packages found for /Volumes/Home/code/unbalance/server/unbalance.go"}


[Error - 6:39:26 AM] unable to check package for file:///Volumes/Home/code/unbalance/server/unbalance.go: no packages found for /Volumes/Home/code/unbalance/server/unbalance.go
[Trace - 6:39:26 AM] Received response 'textDocument/documentSymbol - (1)' in 1090ms.
Params: []


[Trace - 6:39:26 AM] Received notification 'window/logMessage'.
Params: {"type":1,"message":"unable to check package for file:///Volumes/Home/code/unbalance/server/unbalance.go: no packages found for /Volumes/Home/code/unbalance/server/unbalance.go"}


[Error - 6:39:26 AM] unable to check package for file:///Volumes/Home/code/unbalance/server/unbalance.go: no packages found for /Volumes/Home/code/unbalance/server/unbalance.go
[Trace - 6:39:27 AM] Received notification 'window/logMessage'.
Params: {"type":1,"message":"unable to check package for file:///Volumes/Home/code/unbalance/server/unbalance.go: no packages found for /Volumes/Home/code/unbalance/server/unbalance.go"}


[Error - 6:39:27 AM] unable to check package for file:///Volumes/Home/code/unbalance/server/unbalance.go: no packages found for /Volumes/Home/code/unbalance/server/unbalance.go
[Trace - 6:39:27 AM] Received notification 'window/logMessage'.
Params: {"type":1,"message":"unable to check package for file:///Volumes/Home/code/unbalance/server/unbalance.go: no packages found for /Volumes/Home/code/unbalance/server/unbalance.go"}


[Error - 6:39:27 AM] unable to check package for file:///Volumes/Home/code/unbalance/server/unbalance.go: no packages found for /Volumes/Home/code/unbalance/server/unbalance.go
[Trace - 6:39:28 AM] Received notification 'window/logMessage'.
Params: {"type":1,"message":"unable to check package for file:///Volumes/Home/code/unbalance/server/unbalance.go: no packages found for /Volumes/Home/code/unbalance/server/unbalance.go"}


[Error - 6:39:28 AM] unable to check package for file:///Volumes/Home/code/unbalance/server/unbalance.go: no packages found for /Volumes/Home/code/unbalance/server/unbalance.go
[Trace - 6:39:28 AM] Received notification 'window/logMessage'.
Params: {"type":1,"message":"unable to check package for file:///Volumes/Home/code/unbalance/server/unbalance.go: no packages found for /Volumes/Home/code/unbalance/server/unbalance.go"}


[Error - 6:39:28 AM] send textDocument/codeAction#2 no file information for file:///Volumes/Home/code/unbalance/server/unbalance.go


[Trace - 6:39:28 AM] Received notification 'window/logMessage'.
Params: {"type":1,"message":"failed to deliver diagnostic for file:///Volumes/Home/code/unbalance/no%20packages%20found%20for%20/Volumes/Home/code/unbalance/server/unbalance.go: stat /Volumes/Home/code/unbalance/no packages found for /Volumes/Home/code/unbalance/server/unbalance.go: no such file or directory"}


[Error - 6:39:28 AM] unable to check package for file:///Volumes/Home/code/unbalance/server/unbalance.go: no packages found for /Volumes/Home/code/unbalance/server/unbalance.go
[Error - 6:39:28 AM] Request textDocument/codeAction failed.
  Message: no file information for file:///Volumes/Home/code/unbalance/server/unbalance.go
  Code: 0 
[Error - 6:39:28 AM] failed to deliver diagnostic for file:///Volumes/Home/code/unbalance/no%20packages%20found%20for%20/Volumes/Home/code/unbalance/server/unbalance.go: stat /Volumes/Home/code/unbalance/no packages found for /Volumes/Home/code/unbalance/server/unbalance.go: no such file or directory
[Trace - 6:39:28 AM] Received notification 'window/logMessage'.
Params: {"type":1,"message":"unable to check package for file:///Volumes/Home/code/unbalance/server/unbalance.go: no packages found for /Volumes/Home/code/unbalance/server/unbalance.go"}


[Error - 6:39:28 AM] unable to check package for file:///Volumes/Home/code/unbalance/server/unbalance.go: no packages found for /Volumes/Home/code/unbalance/server/unbalance.go
[Trace - 6:39:29 AM] Received notification 'window/logMessage'.
Params: {"type":1,"message":"unable to check package for file:///Volumes/Home/code/unbalance/server/unbalance.go: no packages found for /Volumes/Home/code/unbalance/server/unbalance.go"}


[Error - 6:39:29 AM] send textDocument/documentLink#3 no AST for file:///Volumes/Home/code/unbalance/server/unbalance.go


[Error - 6:39:29 AM] unable to check package for file:///Volumes/Home/code/unbalance/server/unbalance.go: no packages found for /Volumes/Home/code/unbalance/server/unbalance.go
[Error - 6:39:29 AM] Request textDocument/documentLink failed.
  Message: no AST for file:///Volumes/Home/code/unbalance/server/unbalance.go
  Code: 0 

@jbrodriguez
Copy link
Author

It's doing a stat for

/Volumes/Home/code/unbalance/no packages found for /Volumes/Home/code/unbalance/server/unbalance.go,

which certainly doesn't exist 🤷🏻‍♂️

@stamblerre
Copy link
Contributor

Thank you for the report, this seems to be a duplicate of #32603. Closing as a duplicate, but I will definitely be investigating this issue.

@golang golang locked and limited conversation to collaborators Jun 13, 2020
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.
Projects
None yet
Development

No branches or pull requests

5 participants