You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Then, open the bug directory in VS Code (with the Go extension set up of course), navigate to main.go, and select some text.
What did you expect to see?
Nothing happens.
What did you see instead?
gopls crashes repeatedly with the following error log and stack trace:
[Error - 11:51:22 PM] failed to deliver diagnostic for file:///Users/dpinela/Desktop/bug/no%20packages%20found%20for%20/Users/dpinela/Desktop/bug/x/main.go: stat /Users/dpinela/Desktop/bug/no packages found for /Users/dpinela/Desktop/bug/x/main.go: no such file or directory
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x132a235]
goroutine 18 [running]:
go/token.(*File).Name(...)
/usr/local/Cellar/go/1.12.2/libexec/src/go/token/position.go:110
golang.org/x/tools/internal/lsp/source.Imports(0x14f47c0, 0xc00008c140, 0x14f88c0, 0xc0002a4000, 0xc0000c3640, 0x4, 0x7, 0x6, 0xc0000a4f50, 0xc0000c3640, ...)
/Users/dpinela/dev/golang-dev/tools/internal/lsp/source/format.go:56 +0x75
golang.org/x/tools/internal/lsp.organizeImports(0x14f47c0, 0xc00008c140, 0x14fa0a0, 0xc00018a480, 0xc00022c3f0, 0x2b, 0x1, 0x4, 0x3, 0x1, ...)
/Users/dpinela/dev/golang-dev/tools/internal/lsp/code_action.go:82 +0x1a9
golang.org/x/tools/internal/lsp.(*Server).codeAction(0xc00016c4d0, 0x14f47c0, 0xc00008c140, 0xc000230120, 0xc000230120, 0x0, 0x0, 0x0, 0xc000184460)
/Users/dpinela/dev/golang-dev/tools/internal/lsp/code_action.go:32 +0x1f1
golang.org/x/tools/internal/lsp.(*Server).CodeAction(0xc00016c4d0, 0x14f47c0, 0xc00008c140, 0xc000230120, 0xc000230120, 0x0, 0x0, 0x0, 0x0)
/Users/dpinela/dev/golang-dev/tools/internal/lsp/server.go:202 +0x4d
golang.org/x/tools/internal/lsp/protocol.serverHandler.func1(0x14f47c0, 0xc00008c140, 0xc00016c540, 0xc0002181c0)
/Users/dpinela/dev/golang-dev/tools/internal/lsp/protocol/tsserver.go:366 +0x2e77
golang.org/x/tools/internal/jsonrpc2.(*Conn).Run.func1(0xc0000a0a80, 0xc00016c540)
/Users/dpinela/dev/golang-dev/tools/internal/jsonrpc2/jsonrpc2.go:276 +0xda
created by golang.org/x/tools/internal/jsonrpc2.(*Conn).Run
/Users/dpinela/dev/golang-dev/tools/internal/jsonrpc2/jsonrpc2.go:270 +0xba
The error seems to stop occurring if I replace "blorp" in the files with "x". I'm not sure why. It also does not occur when the go.mod is at the root of the workspace.
The text was updated successfully, but these errors were encountered:
For gopls to work with modules, VSCode has to be opened at the module root. Otherwise, gopls has no way of knowing the module root. I did add a check to avoid the crash.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes (built gopls at
d88f79806bbd013f54a668506864ce559edf6f0a
)gopls build info:
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Create the following directory structure:
Contents of go.mod:
Contents of main.go:
Then, open the
bug
directory in VS Code (with the Go extension set up of course), navigate to main.go, and select some text.What did you expect to see?
Nothing happens.
What did you see instead?
gopls crashes repeatedly with the following error log and stack trace:
The error seems to stop occurring if I replace "blorp" in the files with "x". I'm not sure why. It also does not occur when the go.mod is at the root of the workspace.
The text was updated successfully, but these errors were encountered: