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: panic with invalid go.mod entry #35599

muirdm opened this issue Nov 14, 2019 · 2 comments

x/tools/gopls: panic with invalid go.mod entry #35599

muirdm opened this issue Nov 14, 2019 · 2 comments


Copy link

@muirdm muirdm commented Nov 14, 2019

I was playing around with my go.mod for personal reasons and had left it with an invalid "require":

module foo

go 1.13

require v1.2.3-456

gopls panics on startup after the "go list" error.

[Trace - 03:09:47 PM] Received notification 'window/logMessage'.
Params: {
  "message": "2019/11/14 15:09:47 : error loading packages: go [list -e -json -compiled=true -test=true -export=false -deps=true -find=false -- ./...]: exit status 1: go: unrecognized import path \"\" (parse no go-import meta tags ())\n",
  "type": 1
panic: runtime error: index out of range [0] with length 0

goroutine 52 [running]:*session).bestView(0xc0000eda20, 0xc0003a6630, 0x25, 0x0, 0x0)
	/Users/muir/projects/tools/internal/lsp/cache/session.go:226 +0x18f*session).DidOpen(0xc0000eda20, 0x19b32c0, 0xc00026d380, 0xc0003a6630, 0x25, 0x0, 0x4010000000000000, 0xc0003741e0, 0x51, 0x60, ...)
	/Users/muir/projects/tools/internal/lsp/cache/session.go:294 +0x2be*Server).didOpen(0xc000265200, 0x19b32c0, 0xc00026d380, 0xc00034e2c0, 0x0, 0xc0003722c0)
	/Users/muir/projects/tools/internal/lsp/text_synchronization.go:30 +0x18c*Server).DidOpen(0xc000265200, 0x19b32c0, 0xc00026d380, 0xc00034e2c0, 0xc00034e2c0, 0x0)
	/Users/muir/projects/tools/internal/lsp/server.go:135 +0x49, 0xc000265200, 0x19b32c0, 0xc00026d380, 0xc000272bc0, 0xc00026d300, 0xc00020ec80)
	/Users/muir/projects/tools/internal/lsp/protocol/tsserver.go:111 +0x1b66*Conn).Run.func1(0xc0000dcba0, 0xc000272bc0, 0xc000265260, 0x19b32c0, 0xc00026d380, 0x0, 0x0, 0xc000213730)
	/Users/muir/projects/tools/internal/jsonrpc2/jsonrpc2.go:370 +0x170
created by*Conn).Run
	/Users/muir/projects/tools/internal/jsonrpc2/jsonrpc2.go:354 +0x877
@gopherbot gopherbot added this to the Unreleased milestone Nov 14, 2019
Copy link

@gopherbot gopherbot commented Nov 14, 2019

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.

Copy link

@gopherbot gopherbot commented Nov 15, 2019

Change mentions this issue: internal/lsp: fix panic in bestView

gopherbot pushed a commit to golang/tools that referenced this issue Nov 16, 2019
Rather than panicking when we have not created any views for the packages,
we should show a reasonable error to the user. This change propagates the
errors to the user.

Updates golang/go#35599

Change-Id: I49789d8ce18e154f111bc3584488f468a129e30c
Run-TryBot: Rebecca Stambler <>
TryBot-Result: Gobot Gobot <>
Reviewed-by: Michael Matloob <>
@stamblerre stamblerre closed this Dec 4, 2019
@golang golang locked and limited conversation to collaborators Dec 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants