rgoussu@goussu: ~/library/go/toolchain
~/library/go/toolchain cat gopls.md

gopls — the language server

# gopls, Go's single official LSP server — completion, refactors, inlay hints, diagnostics, and module-aware workspace handling for every editor.

Conceptsaved 2026-08-09 #go#tooling#lsp#editors

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 go command, so it enforces the same module and workspace rules as builds — a go.work file is how you make it see multiple modules at once; code outside a module gets degraded service.
  • Analysis integration: runs the go vet analyzer 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