Documentation
¶
Overview ¶
Package domain provides domain errors and port interfaces. It has no dependencies on infrastructure (database, HTTP, config), so use cases can depend only on domain.
Role in architecture:
- Core: defines shared errors and interfaces that use cases depend on.
- Implementations of ports live in infrastructure (e.g. repositories package).
Responsibilities:
- Define sentinel errors (ErrNotFound, ErrUnauthorized) for use-case and handler error handling.
- Define port interfaces (e.g. GetByID in subpackage port) that use cases call and infrastructure implements.
This package must NOT:
- Import database, redis, config, or HTTP packages.
- Contain business logic; it only defines contracts and errors.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = errors.New("not found") )
Sentinel errors for use cases and handlers. Use with errors.Is so handlers can map to HTTP status.
ErrNotFound: return when an entity is not found (e.g. repo.GetByID returns notFound). ErrUnauthorized: return when the operation requires authentication or the credentials are invalid.
Wrap with fmt.Errorf("context: %w", ErrNotFound) when adding context; handlers should still use errors.Is(err, domain.ErrNotFound).
Functions ¶
This section is empty.
Types ¶
This section is empty.