Go Language Server
go-langserver is a Go language server that
speaks
Language Server Protocol. It
supports editor features such as go-to-definition, hover, and find-references
for Go projects.
Open in Sourcegraph
To build and install the standalone go-langserver
run
go get -u github.com/sourcegraph/go-langserver
Support
| Hover | Jump to def | Find references | Workspace symbols | VFS extension | Isolated | Parallel |
---|
Go | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
InitializationOptions
If you are a client wanting to integrate go-langserver, you can use the following as initializationOptions
in your initialize request to adjust the behaviour:
interface GoInitializationOptions {
funcSnippetEnabled?: boolean;
gocodeCompletionEnabled?: boolean;
formatTool?: "goimports" | "gofmt";
goimportsLocalPrefix?: string;
maxParallelism?: number;
useBinaryPkgCache?: boolean;
}
Profiling
If you run into performance issues while using the language server, it can be very helpful to attach a CPU or memory profile with the issue report. To capture one, first install Go and then:
Capture a heap (memory) profile:
go tool pprof -svg $GOPATH/bin/go-langserver http://localhost:6060/debug/pprof/heap > heap.svg
Capture a CPU profile:
go tool pprof -svg $GOPATH/bin/go-langserver http://localhost:6060/debug/pprof/profile > cpu.svg
Since these capture the active resource usage, it's best to run these commands while the issue is occurring (i.e. while memory or CPU is high).