Overview
gopls is the official Go language server, maintained by the Go team. Every serious
editor — VS Code, Neovim, Emacs, Helix, Zed — speaks LSP to the same binary, so
completion, diagnostics, and refactors behave identically everywhere. There is no
per-IDE Go engine to diverge (GoLand being the notable holdout with its own).
Key points
- One implementation: editor plugins are thin; the Go semantics live in gopls.
Upgrade with
go install golang.org/x/tools/gopls@latest, independent of the editor. - Core LSP surface: completion, hover docs, go-to-definition/implementation, find-references, rename across packages, semantic tokens for accurate highlighting.
- Refactors: extract function/variable, inline call, method stubbing for unfilled interfaces, struct-tag and loop rewrites offered as code actions.
- Inlay hints: inline display of parameter names, inferred type arguments, and composite-literal field names — opt-in per hint kind.
- Module-aware by construction: gopls loads code through the
gocommand, so it enforces the same module and workspace rules as builds — ago.workfile is how you make it see multiple modules at once; code outside a module gets degraded service. - Analysis integration: runs the
go vetanalyzer suite live as you type, plus extra analyzers (unused parameters, nilness, an embedded subset of staticcheck's checks, opt-in) — findings arrive as diagnostics with quick fixes. - Formatting: applies gofmt on save and organizes imports goimports-style through the LSP formatting hooks — the editor never needs the standalone binaries.
Examples
// VS Code settings.json
"gopls": {
"ui.semanticTokens": true,
"ui.inlayhint.hints": { "parameterNames": true, "assignVariableTypes": true },
"ui.diagnostic.staticcheck": true
}
Related
- The go command & tool catalog — parent catalog of the toolchain.
- Delve — the debugging half of editor integration, via DAP as gopls is via LSP.
- gofmt & goimports — the formatters gopls applies on save.
- staticcheck & golangci-lint — the deeper lint ecosystem gopls partially embeds.
- The JDK & its tools — contrast: the JVM world grew per-IDE compiler frontends where Go standardized on one server.