CLAUDE.md 445
Go マイクロサービス
Goマイクロサービス開発ルール。クリーンアーキテクチャ、gRPC、構造化ロギング。
CLAUDE.md 34 lines
# CLAUDE.md
## Overview
Go microservice following clean architecture principles.
## Project Structure
```
cmd/ - Application entrypoints
internal/
domain/ - Business entities and interfaces
usecase/ - Business logic (depends only on domain)
adapter/ - Interface adapters (HTTP handlers, gRPC, DB repos)
infra/ - External services (DB connections, message queues)
pkg/ - Shared utilities (can be imported by other services)
```
## Rules
- No package-level variables (except errors and constants)
- All errors must be wrapped with fmt.Errorf("context: %w", err)
- Use context.Context as first parameter for all functions that do I/O
- Table-driven tests for all business logic
- No init() functions
## Dependencies
- domain/ imports NOTHING from other internal packages
- usecase/ imports only domain/
- adapter/ imports domain/ and usecase/
- infra/ imports domain/ only
## Concurrency
- Use errgroup for parallel operations
- Always set timeouts on context
- Close channels from sender side only
- Use sync.Once for lazy initialization