golang-gopls

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

Updated Jun 30, 2026
One-click install
npx skills add https://github.com/santoshkal/chezmoi --skill golang-gopls-santoshkal
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: golang-gopls
Source: https://github.com/santoshkal/chezmoi/tree/main/private_dot_config/opencode/skills/Golang/skills/golang-gopls
Command: npx skills add https://github.com/santoshkal/chezmoi --skill golang-gopls-santoshkal

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 semantic meaning — types, call graphs, interface satisfaction, and build-tag scoping. This Skill gives an AI agent access to gopls, the official Go language server, so it can answer questions about the resolved local build (definitions, references, diagnostics, safe renames) instead of guessing from grep output. ## Core Features & Use Cases - Semantic navigation: go-to-definition, find references, implementation and call hierarchy, workspace symbol search, and package API discovery via gopls's MCP tools, Claude Code's native LSP tool, or the gopls CLI. - Diagnostics and safety: compiler and analyzer diagnostics after every edit, plus an on-demand go_vulncheck reachability check after workspace detection or go.mod changes. - Refactoring: safe rename that blocks changes breaking interface satisfaction, extract/inline refactors, and the refactor.rewrite family (fill struct, fill switch, invert if, add struct tags, implement interface). - Use Case: Before renaming a method used across a monorepo, 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 find every reference to a Go function in this workspace and rename it safely using gopls.

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, which blocks renames that would break interface satisfaction.

What is the difference between gopls MCP tools and the gopls CLI?▼

The MCP server tools take names, paths, and fuzzy queries, making them the preferred interface for agents. The CLI uses file:line:col positions and is documented by the Go team as experimental and debugging-only, so it serves as a fallback when neither MCP nor the native LSP tool is wired up.

Does gopls work with Go packages not in my go.mod?▼

No. gopls only reasons about code present and resolvable in the local build — the workspace plus dependencies pinned in go.sum, including replace directives. For packages not yet added, such as version history or licenses, use a pkg.go.dev-oriented tool instead.

Why does gopls references miss matches in other build-tagged files?▼

Reference 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 the query under the relevant GOOS or set buildFlags with the appropriate -tags value.

How do I enable the native LSP tool for gopls in Claude Code?▼

Set ENABLE_LSP_TOOL=1, install gopls with go install golang.org/x/tools/gopls@latest, and install the gopls-lsp plugin from the claude-plugins-official marketplace. Its unique benefit is compiler diagnostics pushed automatically after every edit.

When should I use govulncheck instead of gopls go_vulncheck?▼

Use gopls's go_vulncheck for a lightweight on-demand reachability check after workspace detection or a go.mod change. For a comprehensive whole-tree vulnerability audit such as CI gates or periodic sweeps, use the standalone govulncheck tool instead.