go-expert
Skill5 starsChanged 3 months agoMITView on GitHub
Use when writing or reviewing Go backend services - go.mod, *.go files, net/http handlers, pgx/sqlc database code, goroutines, context.Context plumbing, or failing `go test` runs. Builds HTTP APIs on the Go 1.22+ stdlib router, fixes error-wrapping and context-cancellation bugs, designs leak-free goroutine lifecycles with errgroup, and wires pgx/sqlc data layers. Invoke for HTTP routing, error handling, concurrency, database access, slog logging, project layout, or table-driven tests.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- techbuzzz/awesome-opencodetheir own version, first seen Jul 17, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- techbuzzz/awesome-opencode★ 2same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository15 other files it gives its agents.
- docker-expertSkill
- engineering-rulesSkill
- fastapi-expertSkill
- fastify-expertSkill
- flutter-expertSkill
- jetpack-compose-expertSkill
- mobile-qa-expertSkill
- nestjs-expertSkill
- playwright-expertSkill
- react-expertSkill
- react-native-expertSkill
- remix-expertSkill
- swiftui-expertSkill
- terraform-expertSkill
- vue-expertSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 1 is distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 22
Add or refactor database access with pgx v5 and sqlc (transactions, pooling, migrations)
- Very specific: line 23
Write table-driven tests, integration tests with testcontainers, or fix -race failures
- Very specific: line 30
Implement: - Write the change following the patterns below and in the loaded references.
- Very specific: line 31
Verify (vet + lint): - Run go vet ./..., then golangci-lint run ./...
- Very specific: line 121
Premature
pkg/and giantutilpackages: Start with cmd/<service>/main.go (wiring only) and internal/<domain> packages named by what …
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Go Expert
Senior Go backend engineer for Go 1.23+ services: stdlib-first HTTP, disciplined error and context handling, leak-free concurrency, and pgx/sqlc data access.
When to Use This Skill
- Build or extend an HTTP API/service in Go (handlers, routing, middleware, graceful shutdown)
- Fix error handling: wrapping with
%w,errors.Is/errors.As, sentinel vs typed errors - Debug or design concurrency: goroutine leaks,
errgroup, channels, worker pools, cancellation - Add or refactor database access with pgx v5 and sqlc (transactions, pooling, migrations)
- Write table-driven tests, integration tests with testcontainers, or fix
-racefailures - Review Go code for idiom violations, over-abstraction, or misuse of generics/interfaces
- Lay out a new Go service (
cmd/,internal/, module structure)
Core Workflow
- Analyze - Read
go.modfor the Go version and existing dependencies before adding any. Check for an existing router, logger, and DB layer and match them - do not introduce chi/zap/GORM into a stdlib/slog/pgx codebase. Look forinternal/structure and follow the established package boundaries. - Implement - Write the change following the patterns below and in the loaded references. Stdlib first: net/http ServeMux,
log/slog,database/sqlsemantics via pgx. Accept interfaces, return concrete types. Every function that does I/O takesctx context.Contextas its first parameter. - Verify (vet + lint) - Run
go vet ./..., thengolangci-lint run ./...if the repo has a.golangci.yml(or golangci-lint is installed). If either reports problems, fix all reported issues and re-run until clean before proceeding. Do not suppress findings with//nolintunless there is a documented false positive. - Test - Write or update table-driven tests for the change, then run
go test -race ./.... If any test fails or the race detector reports a data race, fix all reported issues and re-run until clean. Never delete or skip a failing test to get green; fix the code or the test's expectations deliberately. - Prove it works - Build and run the actual entrypoint (
go run ./cmd/<service>or the repo's make target) and exercise the changed behavior:curlthe new endpoint, run the migration, or trigger the job. For services, confirm graceful shutdown works (Ctrl-C returns promptly, no goroutines hang). If the run fails, fix and re-run until the observed behavior matches the requirement.
Reference Guide
Load detailed guidance only when the task needs it:
| Topic | Reference | Load When |
| HTTP services | references/http-services.md | Handlers, routing, middleware, ServeMux vs chi/echo, graceful shutdown, timeouts, JSON APIs |
| Errors & context | references/errors-and-context.md | Error wrapping, sentinel/typed errors, errors.Is/As, context propagation, cancellation, deadlines |
| Concurrency | references/concurrency.md | Goroutines, channels, errgroup, worker pools, goroutine leaks, sync primitives, data races |
| Database | references/database-pgx-sqlc.md | Postgres access, pgx v5 pools, sqlc codegen, transactions, migrations, why not GORM |
| Testing | references/testing.md | Table-driven tests, subtests, testcontainers, httptest, race detector, benchmarks, fuzzing |
Key Patterns
Go 1.22+ ServeMux - method + wildcard routing, no framework needed:
mux := http.NewServeMux()
mux.HandleFunc("GET /api/orders/{id}", h.getOrder) // method-scoped since 1.22
mux.HandleFunc("POST /api/orders", h.createOrder)
mux.HandleFunc("GET /healthz", h.health)
func (h *Handler) getOrder(w http.ResponseWriter, r *http.Request) {
id := r.PathValue("id") // wildcard extraction is stdlib now
order, err := h.store.GetOrder(r.Context(), id)
if errors.Is(err, store.ErrNotFound) {
http.Error(w, "order not found", http.StatusNotFound)
return
}
if err != nil {
h.log.ErrorContext(r.Context(), "get order", "id", id, "err", err)
http.Error(w, "internal error", http.StatusInternalServerError)
return
}
writeJSON(w, http.StatusOK, order)
}Error wrapping - %w once per level, decide with errors.Is/As:
var ErrNotFound = errors.New("not found") // sentinel: caller branches on identity
func (s *Store) GetOrder(ctx context.Context, id string) (Order, error) {
row, err := s.q.GetOrder(ctx, id)
if errors.Is(err, pgx.ErrNoRows) {
return Order{}, fmt.Errorf("order %s: %w", id, ErrNotFound) // translate driver error at the boundary
}
if err != nil {
return Order{}, fmt.Errorf("get order %s: %w", id, err)
}
return fromRow(row), nil
}errgroup - bounded, cancellable, leak-free fan-out:
g, ctx := errgroup.WithContext(ctx) // ctx cancels when any task errors
g.SetLimit(8) // bound concurrency; never spawn unbounded goroutines
for _, id := range ids {
g.Go(func() error { // Go 1.22+: loop var is per-iteration, no capture bug
return process(ctx, id) // must honor ctx or the group can't stop it
})
}
if err := g.Wait(); err != nil { // first error; all goroutines finished
return fmt.Errorf("process batch: %w", err)
}slog - structured, context-aware logging (not fmt.Printf, not logrus):
log := slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{Level: slog.LevelInfo}))
slog.SetDefault(log)
log.InfoContext(ctx, "order created", "order_id", o.ID, "user_id", o.UserID, "amount_cents", o.Amount)Common Mistakes
- Reaching for chi/echo/gin by default. Since Go 1.22,
http.ServeMuxhandles method routing and path wildcards (GET /users/{id},r.PathValue). Use a framework only for real needs: route groups with shared middleware stacks, path regexes, or an existing codebase already using one. Never mix two routers. - Storing
context.Contextin a struct field. Context flows through call chains as the first function parameter, full stop. A struct-held ctx outlives its request and silently breaks cancellation. The only sanctioned exception ishttp.Request, which predates the rule. - Wrapping every error with
%wreflexively - or with none. Wrap with%wwhen callers may need to branch (errors.Is/As) or when adding operation context; use%v(or a new error) at boundaries where you want to stop callers depending on internals (e.g., hidepgx.ErrNoRowsbehind your ownErrNotFound).err.Error() == "..."string comparison is always wrong. - Fire-and-forget goroutines. Every
gostatement needs an answer to "how does this goroutine stop, and who sees its error?" Useerrgroup.WithContextfor request-scoped work and an explicit shutdown signal (ctx.Done()) +Waitfor background workers. A goroutine blocked forever on an unread channel is a leak the race detector will not find. - Generics where an interface (or nothing) belongs. Use type parameters for data structures and slice/map helpers with two-plus concrete instantiations. Do not write
func Process[T any](...)whenTis only ever one type, constrain to a one-method interface (just take the interface), or build generic "repository" abstractions over sqlc. - ORMs (GORM/ent) as the default. For Postgres services, use pgx v5 + sqlc: SQL you can read and EXPLAIN, compile-time-checked query results, no N+1 surprises. Reach for ent only when you genuinely need a graph schema with typed traversals.
- Premature
pkg/and giantutilpackages. Start withcmd/<service>/main.go(wiring only) andinternal/<domain>packages named by what they provide (billing,store), not by kind (models,helpers,utils).pkg/earns its place only when an external module actually imports the code. http.ListenAndServe(":8080", mux)in production. Zero timeouts means slow-loris and leaked connections. ConfigureReadHeaderTimeout,ReadTimeout,WriteTimeout,IdleTimeout, and shut down withsrv.Shutdown(ctx)on SIGTERM.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

