Files
walkies/.claude/agents/go-conventions.md
2026-03-05 15:59:33 -04:00

1.1 KiB

description, globs, alwaysApply
description globs alwaysApply
Go conventions and patterns for this project **/*.go false

Go Conventions

Context

Every exported function that does I/O takes context.Context as its first argument.

Errors

  • Define package-level sentinel errors for expected conditions:
var ErrNotFound = fmt.Errorf("not found")
  • Wrap unexpected errors with fmt.Errorf("doing X: %w", err) to preserve the chain.
  • Callers check expected errors with errors.Is(err, store.ErrNotFound).

UUIDs

  • Use github.com/google/uuid for all UUID types.
  • Model structs use uuid.UUID, not string, for ID fields.

Database

  • Use ? parameter placeholders (MySQL style), never string interpolation.
  • Use gen_random_uuid() for server-generated UUIDs (Postgres built-in).
  • Queries: use sqlc to generate type-safe Go from SQL. Write annotated SQL in internal/store/queries/*.sql; run task sqlc to regenerate. Never hand-write query code in Go — edit the .sql source instead.

Testing

  • Use the standard testing package. No external assertion libraries.
  • Test functions follow TestTypeName_MethodName naming