domain

package
v0.3.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 28, 2026 License: MIT Imports: 1 Imported by: 0

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

View Source
var (
	ErrNotFound     = errors.New("not found")
	ErrUnauthorized = errors.New("unauthorized")
)

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.

Directories

Path Synopsis
Package port defines repository and other ports (interfaces) used by use cases.
Package port defines repository and other ports (interfaces) used by use cases.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL