sourcegraph / go-langserver

Go language server to add Go support to editors and other tools that use the Language Server Protocol (LSP)
https://sourcegraph.com
MIT License
1.17k stars 89 forks source link

Getting weird "PANIC" in my go-langserver #317

Closed esn89 closed 6 years ago

esn89 commented 6 years ago

I am using neovim with LanguageClient-neovim with the gocodecompletion enabled:

let g:LanguageClient_serverCommands = {
    \'go' : ['/Users/esn89/.go/bin/go-langserver', '-gocodecompletion']
    \}

However, when it tries to show me suggestions I get things like: https://i.imgur.com/D9MNz6y.png

Funnily enough, it used to work a couple of weeks ago. Any ideas?

For reference, the go-langserver I am using is v2-dev.

chemzqm commented 6 years ago

Same issue on mac.

seagle0128 commented 6 years ago

Same issue here, with Go 1.11 on mac.

panic: unknown export format version -1 ("i\x00\xe9\x03\xc6\x06\x18$GOROOT/src/fmt/print.go\x00\x05Write\x01b\x01n\x03err\x05Width\x03wid\x02ok\tPrecision\x04prec\x04Flag\x01c\x06Format\x01f\x05State\x06String\bGoString\x01w\x06Writer\x02io\x06format\x01a\aesc:0x1\aesc:0x9\x17$GOROOT/src/fmt/scan.go\bReadRune\x01r\x04size")
1(runtime.call32): /usr/local/Cellar/go/1.11/libexec/src/runtime/asm_amd64.s:522
2(runtime.gopanic): /usr/local/Cellar/go/1.11/libexec/src/runtime/panic.go:513
3(github.com/sourcegraph/go-langserver/langserver/internal/gocode.(*gc_bin_parser).parse_export): /Users/vincent/go/src/github.com/sourcegraph/go-langserver/langserver/internal/gocode/package_bin.go:126
4(github.com/sourcegraph/go-langserver/langserver/internal/gocode.(*package_file_cache).process_package_data): /Users/vincent/go/src/github.com/sourcegraph/go-langserver/langserver/internal/gocode/package.go:132
5(github.com/sourcegraph/go-langserver/langserver/internal/gocode.(*package_file_cache).update_cache): /Users/vincent/go/src/github.com/sourcegraph/go-langserver/langserver/internal/gocode/package.go:92
6(github.com/sourcegraph/go-langserver/langserver/internal/gocode.update_packages.func1): /Users/vincent/go/src/github.com/sourcegraph/go-langserver/langserver/internal/gocode/autocompletecontext.go:439
7(runtime.goexit): /usr/local/Cellar/go/1.11/libexec/src/runtime/asm_amd64.s:1333
diegs commented 6 years ago

FWIW I did a rm -rf on the cache in $GOPATH/pkg and that seemed to fix it...

slimsag commented 6 years ago

I think this will be fixed once https://github.com/sourcegraph/go-langserver/pull/305 is merged

anjmao commented 6 years ago

@esn89 If you can checkout #305 locally and check if it works for you that would be great, I tested this PR with vscode only.

git clone git@github.com:anjmao/go-langserver.git
cd go-langserver
git checkout gocode
go install ./...
bittopaz commented 6 years ago

@anjmao I have just tried your branch locally. And I'm using Emacs with LSP enabled.

The panic error is gone. But I get the errors as below when auto-complete:

Error from the Language Server: no declaration found for s.L (Unknown error) [2 times]
(No changes need to be saved)
SPC m e e is undefined
Error from the Language Server: no declaration found for s.L (Unknown error)
Error from the Language Server: no declaration found for s.La (Unknown error)
Error from the Language Server: no declaration found for s.Las (Unknown error)
Error from the Language Server: no declaration found for s.Last (Unknown error)
Error from the Language Server: no declaration found for s.LastP (Unknown error)
Error from the Language Server: no declaration found for s.LastPi (Unknown error)
Error from the Language Server: no declaration found for s.LastPie (Unknown error)
Error from the Language Server: no declaration found for s.LastPiep (Unknown error) [2 times]
Error from the Language Server: no declaration found for s.LastPie (Unknown error)
Error from the Language Server: no declaration found for s.LastPi (Unknown error)
Error from the Language Server: no declaration found for s.LastPip (Unknown error)
Error from the Language Server: no declaration found for s.LastPipe (Unknown error)
Error from the Language Server: no declaration found for s.LastPipel (Unknown error)
Error from the Language Server: no declaration found for s.LastPipeli (Unknown error)
Error from the Language Server: no declaration found for s.LastPipelin (Unknown error) [4 times]

Not sure if this is related...

anjmao commented 6 years ago

@bittopaz As I see you are getting it from https://github.com/sourcegraph/go-langserver/blob/1fe24b2b3fd1f420474fb872d944d2a1a93ddf63/langserver/internal/godef/godef.go#L89 which is actually another tool.

bittopaz commented 6 years ago

@anjmao Ah I see, thanks.

esn89 commented 6 years ago

it works for me. will it be merged in the next release? :D

keegancsmith commented 6 years ago

I've tagged a new release. Thanks for the report.