beta

Go Backend AGENTS.md

Rules

Agent instructions for Go backend services with standard library patterns.

1903/23/2026
markdown1 file
AGENTS.md860 B

AGENTS.md — Go Backend

Project Structure

Standard Go project layout with cmd/, internal/, pkg/.

Commands

  • go run ./cmd/server — start server
  • go test ./... — run all tests
  • go vet ./... — static analysis
  • golangci-lint run — comprehensive linting

Code Style

  • Follow Effective Go and Go Code Review Comments
  • Use table-driven tests
  • Error wrapping with fmt.Errorf and %w
  • No naked returns
  • Short variable names in small scopes, descriptive in large

Patterns

  • Use interfaces for dependencies (dependency injection)
  • Context propagation through all functions
  • Structured logging with slog
  • Middleware pattern for HTTP handlers
  • Repository pattern for database access

Database

  • Use pgx for PostgreSQL
  • Use squirrel or raw SQL (no ORM)
  • Always use prepared statements
  • Transactions for multi-step operations