golang-gopls

Provides semantic Go code navigation, diagnostics, and refactoring via the gopls language server.

3.1k|206|Updated Mar 21, 2026
One-click install
npx skills add https://github.com/samber/cc-skills-golang --skill golang-gopls
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-gopls
Source: https://github.com/samber/cc-skills-golang/tree/main/skills/golang-gopls
Command: npx skills add https://github.com/samber/cc-skills-golang --skill golang-gopls

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires gopls, and includes references (resource) components.

What problem does it solve?

Navigating and refactoring Go code with plain text search misses types, call graphs, and interface relationships, and manual renames or edits risk breaking the build. This Skill gives an agent semantic code intelligence through gopls, the official Go language server, so questions about the resolved build are answered by meaning rather than by grep.

Core Features & Use Cases

  • Semantic Navigation: Go-to-definition, find references, call and implementation hierarchy, workspace symbol search, and package API discovery via gopls's MCP server, the native LSP tool, or the gopls CLI.
  • Diagnostics & Safety: Compiler and analyzer diagnostics after every edit, plus an on-demand go_vulncheck reachability check for the current build.
  • Safe Refactoring: Rename with interface-satisfaction checks, extract/inline refactors, fill struct/switch, organize imports, formatting, and generated table-driven tests.
  • Use Case: Before renaming a method on a widely used interface, run go_symbol_references to gauge the blast radius, apply the rename with go_rename_symbol, then confirm with go_diagnostics and targeted go test runs.

Quick Start

Ask the agent to use gopls to find every reference to a Go function before renaming it and to run diagnostics on the changed files afterward.

Frequently Asked Questions about golang-gopls

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I find all references to a Go function before renaming it?

Use the go_symbol_references MCP tool or gopls references at a file:line:col position to list every use of the symbol. Run it before modifying any definition to judge the blast radius, then apply the change with go_rename_symbol or gopls rename.

What is the difference between gopls MCP server, the native LSP tool, and the gopls CLI?

The MCP server takes names, paths, and fuzzy queries, suiting agent workflows. The native LSP tool is keyed by line and character and pushes diagnostics automatically after edits. The CLI is an experimental fallback for one-shot scripted checks.

Does gopls work for packages not in my go.mod?

No. gopls only reasons about code present and resolvable in the local build, meaning the workspace plus dependencies pinned in go.sum including replace directives. For ecosystem data like versions, licenses, or importers of packages not yet added, use a pkg.go.dev-based tool instead.

Why does gopls references miss matches in some files?

References results reflect only the build configuration of the queried file, so a query on foo_windows.go will not surface matches in bar_linux.go. Re-run under the relevant GOOS or set buildFlags with the needed build tags.

Can gopls check for vulnerabilities in my Go build?

Yes, the go_vulncheck MCP tool runs a lightweight reachability check showing which known vulnerabilities the current build actually reaches. Run it once after detecting the workspace and again after any go.mod change; use a full govulncheck audit for CI gates.