go-practices

eser's avatarfrom eser

Go conventions for hexagonal architecture, project structure, error handling, testing, and observability. Use when writing Go services.

⭐83stars🔀4forks📁View on GitHub🕐Updated Jan 1, 2026

When & Why to Use This Skill

This Claude skill provides a comprehensive framework for Go development, focusing on hexagonal architecture, standardized project structures, and robust error handling. It helps developers build scalable, maintainable Go services by enforcing clean code principles, decoupled business logic, and advanced testing patterns like race detection and parallel execution.

Use Cases

  • Architecting New Go Services: Designing a decoupled project structure where business logic remains independent of external dependencies using hexagonal architecture principles.
  • Standardizing Error Management: Implementing consistent error wrapping and sentinel error patterns to improve system-wide debugging and error tracking in production environments.
  • Optimizing Testing Workflows: Establishing table-driven tests with race detection and parallel execution to ensure high-quality, thread-safe Go applications.
  • Enhancing System Observability: Integrating OpenTelemetry and structured logging conventions to facilitate better monitoring and performance analysis of Go-based microservices.
namego-practices
descriptionGo conventions for hexagonal architecture, project structure, error handling, testing, and observability. Use when writing Go services.

go-practices

Quick Start

  1. Follow hexagonal architecture: business logic in pkg/api/business/, adapters in pkg/api/adapters/
  2. Use snake_case for all Go files
  3. Wrap errors: fmt.Errorf("%w: %w", ErrSentinelError, err)
  4. Run tests with race detection: go test -race ./...

Key Principles

  • Business logic has NO external dependencies
  • All external interactions through interfaces
  • Composition via AppContext (composition root)
  • Table-driven tests with t.Parallel()
  • OpenTelemetry for observability

References

See rules.md for complete conventions.