Cette page est affichée en anglais. Une traduction française est en cours.
ScriptsJul 21, 2026·3 min de lecture

gopls — The Official Go Language Server

The official Go language server providing IDE features like auto-completion, go-to-definition, and diagnostics to any LSP-compatible editor.

Prêt pour agents

Installation agent prête

Cet actif peut être installé après choix du runtime, vérification du plan et exécution de la commande adaptée.

Native · 98/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
gopls Overview
Commande d'installation directe
npx -y tokrepo@latest install 3c6ad7f3-84e1-11f1-9bc6-00163e2b0d79 --target codex

À exécuter après confirmation du plan en dry-run.

Introduction

gopls (pronounced "go please") is the official language server for Go, maintained by the Go team at Google. It implements the Language Server Protocol to bring rich IDE features — completion, navigation, refactoring, diagnostics — to any editor that speaks LSP.

What gopls Does

  • Provides intelligent auto-completion with type-aware suggestions and documentation
  • Implements go-to-definition, find-references, and rename across packages and modules
  • Runs real-time diagnostics including vet checks, staticcheck, and build errors
  • Supports code actions like organize imports, extract function, and generate tests
  • Handles workspace-wide symbol search and document outline

Architecture Overview

gopls runs as a long-lived process that communicates with editors over JSON-RPC. It loads Go modules using the standard go/packages API and builds an in-memory representation of the workspace. Incremental parsing and caching let it respond to edits without re-analyzing the entire module. It integrates analysis passes from the go/analysis framework for diagnostics.

Self-Hosting & Configuration

  • Install with go install golang.org/x/tools/gopls@latest; no separate runtime needed
  • Configure via editor-specific LSP settings or a gopls JSON settings block
  • Key settings include staticcheck (enable extra linters), gofumpt (stricter formatting), and analyses (toggle individual analyzers)
  • Memory usage scales with workspace size; large monorepos may need tuning via directoryFilters
  • Supports multi-module workspaces via the go.work file

Key Features

  • Zero-config setup for most editors — install and it works with Go modules out of the box
  • Integrated support for go generate, build tags, and CGo
  • Semantic token highlighting for richer syntax coloring
  • Inlay hints for parameter names, type parameters, and composite literal fields
  • Call hierarchy and implementation finder for navigating complex codebases

Comparison with Similar Tools

  • rust-analyzer — Equivalent LSP server for Rust; gopls mirrors its architecture for the Go ecosystem
  • TypeScript Language Server (tsserver) — Built into VS Code; gopls follows a similar approach but as a standalone binary
  • clangd — C/C++ language server; gopls is simpler to set up since Go tooling is self-contained
  • pyright — Python type-checking LSP; gopls benefits from Go's static type system for more precise analysis

FAQ

Q: Which editors support gopls? A: Any LSP-compatible editor including VS Code (via the Go extension), Neovim, Emacs, Sublime Text, and Helix.

Q: Does gopls replace goimports and gofmt? A: gopls runs organize-imports and formatting internally. You can still use standalone tools, but gopls handles them during save if configured.

Q: How much memory does gopls use? A: Typically a few hundred MB for medium projects. Large monorepos may need directoryFilters to limit scope.

Q: Is gopls maintained by the Go team? A: Yes, gopls is an official project under golang.org/x/tools, maintained by Google's Go team.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires