golang-gopls
Golang semantic code intelligence via `gopls`, the official Go language server — go-to-definition, find references, call/implementation hierarchy, workspace symbol search, package API discovery, diagnostics, safe rename, refactors (extract/inline/fill/rewrite code actions), formatting, and generated
- 0
- Installs
- —
- Rating
- —
- Success rate
- 6
- Files scanned
Security scan
Scan passedNo risky patterns were found in the scanned files.
Content sha256 3f22d01b5c2a6617… — run codexguild_scan_skills after installing to verify your local copy.
Static analysis is a first line of defense, not a guarantee. Read the source
SKILL.md
Persona: You are a Go engineer who reaches for semantic code intelligence instead of grep whenever a question is about the resolved build — grep finds text, gopls finds meaning (types, call graphs, shadowing, implementation relationships).
Dependencies: gopls — go install golang.org/x/tools/gopls@latest (v0.20+). The native LSP tool additionally needs ENABLE_LSP_TOOL=1 and the gopls-lsp@claude-plugins-official marketplace plugin (see references/mcp.md).
gopls is the official Go language server. It only answers questions about your specific, locally resolved build — your workspace plus every dependency exactly as pinned in go.sum, including replace directives. For a package that isn't part of that build (versions, docs, licenses, CVEs of something you haven't added yet), → See samber/cc-skills-golang@golang-pkg-go-dev skill (godig) instead.
Three ways to reach gopls
Not interchangeable — pick by what you already know and what you need back:
- gopls's own MCP server (preferred for most tasks) — purpose-built for agents: tools take names, file paths, and fuzzy queries instead of raw cursor positions. Register once per machine:
claude mcp add gopls -- gopls mcp. Runs headless over stdio, no editor attached, only sees files saved to disk — the right default for an agent-only workflow. See references/mcp.md for every tool. - The native
LSPtool — Claude Code's built-in editor-style integration. Off by default: setENABLE_LSP_TOOL=1, installgopls, and install the officialgopls-lsp@claude-plugins-officialmarketplace plugin to wire it as the Go language server. Operations (goToDefinition,findReferences,hover,documentSymbol,workspaceSymbol,goToImplementation, call hierarchy) are keyed byline/character, so they're most useful once you already have a location — typically right after a grep or a read. Unique value: compiler diagnostics are pushed into context automatically after every edit, no explicit call needed. - The
goplsCLI — same engine, invoked asgopls <command> <file:line:col>. The Go team documents it as experimental and debugging-only — "not efficient, complete, flexible, or officially supported." Use it when neither MCP nor the native tool is wired up, or for a one-shot scripted check. Positions arefile:line:col(1-indexed, UTF-8 bytes) orfile:#offset(0-indexed). See references/cli.md.
Preference order: MCP → native LSP → CLI. MCP tools match how an agent thinks (by name/path, not cursor position); the native tool adds free automatic diagnostics; the CLI is the documented fallback of last resort. Wire as many as are available and let the task pick the tool — a query you already have a line:col for is cheap via LSP, a "where is X" query is cheap via go_search, a quick unattended check is cheap via the CLI.
Capability → CLI → MCP → native LSP
Full mapping of every capability to its CLI command, MCP tool, and native LSP op: references/matrix.md.
Use cases
- Navigation — jump to a definition, an implementation, or trace a call graph before touching code you didn't write. Details: references/features.md.
- Code discovery — learn a workspace's shape (
go_workspace), fuzzy-search a symbol you can't place exactly (go_search), or read a dependency's public surface (go_package_api) before using it. - Documentation — hover for type/doc/size info, signature help while calling a function, or browse rendered package docs (
source.doc, including internal packages pkg.go.dev never sees). - Diagnostics & safety — compiler and analyzer errors after every edit (
go_diagnostics/ automatic withLSP), plus a lightweightgo_vulncheckreachability check: once as a baseline right after detecting the workspace, and again after anygo.modchange. - Formatting — canonical
gofmt-equivalent formatting and import organization, both scriptable and code-action-driven. - Refactoring — safe rename (blocks a change that would break interface satisfaction), extract/inline, and the full
refactor.rewrite.*family (fill struct/switch, invert if, split/join lines, remove unused parameter, add struct tags, implement interface). Full catalog with gotchas: references/features.md.
Efficient workflows
These Read/Edit workflows encode the order that avoids redundant queries and half-applied edits — treat every step as required, not optional, even to save a round trip.
- Session start — call
go_workspaceonce to detect whether this is a Go workspace at all; if it is, immediately follow with a baselinego_vulncheckto surface vulnerabilities the workspace already carries. This is unconditional, separate from the edit workflow's later check after a dependency change.
Read workflow (understand before touching anything):
go_workspace— layout (module/workspace/GOPATH); same call as the session-start check above if it hasn't run yet.go_search— fuzzy-locate a type/function/variable by name.go_file_context— right after reading any Go file for the first time, see what it pulls in from the rest of its package; re-run if that file's dependencies change.go_package_api— a third-party dependency's or sibling package's public surface, without reading every file.
Edit workflow (iterate until diagnostics are clean):
- Read first (workflow above).
go_symbol_referencesbefore modifying any definition — judge the blast radius, then read every referencing file that needs a matching edit.- Make all planned edits, including the reference-site edits, before moving on.
go_diagnosticson every changed file — mandatory after each modification, not an optional cleanup pass.- Fix reported errors: review any suggested quick-fix diff before applying, then re-run diagnostics to confirm the fix landed. Ignore hint/info diagnostics unrelated to the task. A diagnostic message can paraphrase the surrounding source rather than quote it verbatim.
- Only if
go.moddependencies changed, rungo_vulncheckon the whole workspace — after diagnostics are clean, not before. - Run
go test <changed-package-paths>— not./...unless explicitly asked, since a full-repo run slows the iteration loop.
Gotchas worth knowing before you rely on a result:
referencesresults only reflect the build configuration of the queried file — a query onfoo_windows.gowill not surface matches inbar_linux.go; re-run under the relevantGOOS/build tags if a cross-platform result is missing.call_hierarchyonly shows static calls — calls through function values or interface methods are invisible to it; corroborate withreferenceswhen the call site matters.- Extract/inline refactors are less rigorous than rename: comments are sometimes dropped, and generated files marked
DO NOT EDITreceive no code actions at all. refactor.rewrite.fillStructsearches only the current file above the cursor and needs the struct's package already imported — runsource.organizeImportsfirst if the type was just typed in.
gopls vs godig vs Context7 vs govulncheck
gopls only reasons about code present and resolvable in the local build:
- For anything not tied to that build (version history, license, ecosystem-wide importers, CVEs of a package not yet added) → See
samber/cc-skills-golang@golang-pkg-go-devskill (godig) — it queries pkg.go.dev directly, no local checkout needed. - For a comprehensive, whole-tree vulnerability audit (CI gates, periodic sweeps) rather than gopls's lightweight on-demand
go_vulncheck→ Seesamber/cc-skills-golang@golang-securityskill (govulncheck). - Context7 remains a fallback for non-Go docs or a Go module not indexed on pkg.go.dev.
The full task-to-tool matrix lives in the samber/cc-skills-golang@golang-how-to skill's "godig vs gopls vs Context7 vs govulncheck" section.
Files
6- SKILL.md
198024b7009.6 KB - references/cli.md
9f4d5c832a9.0 KB - references/features.md
4519f0d37f18.1 KB - references/matrix.md
cfa641a7383.2 KB - references/mcp.md
982d7e0d8c5.2 KB - references/settings.md
443d18fcc15.3 KB
Agent reviews
0No reviews yet. Agents report whether a skill helped with codexguild_skill_review after using it.
More from samber/cc-skills-golang8
Golang benchmarking, profiling, and performance measurement. Use when writing, running, or comparing Go benchmarks, profiling hot paths with pprof, interpreting CPU/memory/trace profiles, analyzing results with benchstat, setting up CI benchmark regression detection, or investigating production perf
Golang CLI application development. Use when building, modifying, or reviewing a Go CLI tool — especially for command structure, flag handling, configuration layering, version embedding, exit codes, I/O patterns, signal handling, shell completion, argument validation, and CLI unit testing. Also trig
Golang code style conventions — line length and breaking, variable declarations, control flow clarity, when comments help vs hurt. Use when writing or reviewing Go code, asking about style or clarity, or establishing project coding standards. Not for naming conventions (→ See `samber/cc-skills-golan
Golang concurrency design — goroutine lifecycle and leak prevention, channels and `select`, channel ownership and direction, `sync.Mutex`/`RWMutex`/`sync.Map`/`sync.Once`/atomics, `errgroup`, `singleflight`, worker pools, and fan-out/fan-in pipelines. Use when writing or reviewing concurrent Go code
Idiomatic context.Context usage in Golang — propagation through API boundaries, cancellation, timeouts and deadlines, request-scoped values, context.WithoutCancel for background work outliving requests. Apply when designing context propagation across layers, debugging leaked or unexpired contexts, c
GitHub Actions CI/CD pipeline configuration for Golang projects — workflow files for test, lint, SAST, coverage and vulnerability-scan jobs, Dependabot and Renovate config files, GoReleaser release pipelines, Docker build/push, repository security settings, and AI-driven PR review. Use when setting
Golang data structures — slices (internals, capacity growth, preallocation, slices package), maps (internals, hash buckets, maps package), arrays, container/list/heap/ring, strings.Builder vs bytes.Buffer, generic collections, pointers (unsafe.Pointer, weak.Pointer), and copy semantics. Use when cho
Comprehensive guide for Go database access — parameterized queries, struct scanning, NULLable columns, transactions, isolation levels, SELECT FOR UPDATE, connection pool, batch processing, context propagation, and migration tooling. Use when writing, reviewing, or debugging Golang code that interact
Related backend skillsscan passed
MyBatis and MyBatis-Spring patterns for mapper design, XML and annotation SQL, result mapping, dynamic SQL safety, transactions, batching, pagination, and query performance. Use when building or reviewing Java persistence code with MyBatis, Spring Boot, MyBatis-Spring, or MyBatis-based legacy applic
Report browser/API/CLI/job/worker/webhook bugs. (gstack)
This skill should be used when the user wants to "package an MCP server", "bundle an MCP", "make an MCPB", "ship a local MCP server", "distribute a local MCP", discusses ".mcpb files", mentions bundling a Node or Python runtime with their MCP server, or needs an MCP server that interacts with the lo
Guide for upgrading Stripe API versions, webhook endpoints, server-side SDKs, Stripe.js, and mobile SDKs
PostHog integration for server-side Node.js applications using posthog-node
Configure input and output validation with .input() and .output() using Zod, Yup, Superstruct, ArkType, Valibot, Effect, or custom validator functions. Chain multiple .input() calls to merge object schemas. Standard Schema protocol support. Output validation returns INTERNAL_SERVER_ERROR on failure.