返回 Skill 列表
extension
分类: 开发与工程无需 API Key

go-practices

Go语言在六边形架构、项目结构、错误处理、测试和可观察性方面的约定。在编写Go服务时使用。

person作者: jakexiaohubgithub

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.