go

Guides writing idiomatic, testable Go code for services, libraries, and CLIs.

5|Updated Jan 31, 2026
One-click install
npx skills add https://github.com/nuggocto/dotfiles --skill go-nuggocto
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go
Source: https://github.com/nuggocto/dotfiles/tree/main/opencode/skills/go
Command: npx skills add https://github.com/nuggocto/dotfiles --skill go-nuggocto

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Writing production-grade Go requires consistent decisions about package layout, error handling, concurrency, toolchain versions, and testing. This Skill encodes those decisions so Go code stays idiomatic, maintainable, and verified against the module's declared Go version. ## Core Features & Use Cases - Architecture and package guidance: Recommends cohesive package layouts, interface placement at consumers, and explicit dependency wiring for services, APIs, workers, and libraries. - Backend stack selection: Provides opinionated options for HTTP (net/http, Chi), PostgreSQL (pgx, sqlc), migrations (Goose), and logging (slog) via the backend-stack reference. - Toolchain and upgrade management: Resolves go.mod and go.work directives, GOTOOLCHAIN policy, and GODEBUG defaults, with a dedicated reference for safe Go version upgrades. - Verification workflow: Covers gofmt, go vet, race tests, benchmarks with benchstat, govulncheck, and integration testing practices. - Use Case: When adding a new HTTP endpoint to a Go microservice, the Skill ensures handlers stay transport-focused, errors are wrapped correctly, context propagates through database calls, and tests run with the race detector. ## Quick Start Ask the assistant to review or write Go code for your service, for example by requesting a new REST endpoint with PostgreSQL persistence following idiomatic Go conventions.

Frequently Asked Questions about go

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

FAQPage Schema
How do I structure a Go backend service project?

Start with the fewest cohesive packages that fit the program, keeping startup and wiring near cmd/ and organizing internal packages around domains. Add transport or storage adapters like internal/httpapi or internal/postgres only when they create a useful boundary.

What HTTP router should I use for a Go API?

Use the standard net/http package by default, adding Chi when its routing features help. Keep handlers and middleware compatible with standard http.Handler contracts, and configure explicit server timeouts and graceful shutdown.

How do I handle errors idiomatically in Go?

Never ignore errors, add context when returning them, and wrap with %w only when callers should inspect the underlying error using errors.Is or errors.As. Log an operational failure once at the boundary that handles it rather than at every layer.

Does the go directive in go.mod affect toolchain selection?

Yes, since Go 1.21 the go directive is a mandatory minimum toolchain requirement and also selects the language version for module packages. Confirm GOTOOLCHAIN, CI images, and release builders all use the intended version when upgrading.

How do I test concurrent Go code safely?

Give every goroutine a clear owner and termination condition, use errgroup.WithContext for related tasks, and avoid unbounded fan-out. Run go test -race ./... for non-trivial concurrent code to detect data races.

When should I upgrade the Go toolchain in an existing project?

Use the latest patch release of a supported Go line since patches carry security and correctness fixes. Read release notes for skipped minor releases, review GODEBUG default changes, and rerun tests, benchmarks, and race checks after upgrading.