shared

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package shared provides shared domain types and utilities.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound      = errors.New("not found")
	ErrAlreadyExists = errors.New("already exists")
	ErrInvalidInput  = errors.New("invalid input")
	ErrUnauthorized  = errors.New("unauthorized")
	ErrForbidden     = errors.New("forbidden")
	ErrInternal      = errors.New("internal error")
	ErrConflict      = errors.New("conflict")
	ErrValidation    = errors.New("validation error")
)

Domain errors.

Functions

func IsAlreadyExists

func IsAlreadyExists(err error) bool

IsAlreadyExists checks if the error is an already exists error.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound checks if the error is a not found error.

func IsValidation

func IsValidation(err error) bool

IsValidation checks if the error is a validation error.

Types

type DomainError

type DomainError struct {
	Code    string
	Message string
	Err     error
}

DomainError represents a domain-specific error.

func NewDomainError

func NewDomainError(code, message string, err error) *DomainError

NewDomainError creates a new DomainError.

func (*DomainError) Error

func (e *DomainError) Error() string

Error implements the error interface.

func (*DomainError) Unwrap

func (e *DomainError) Unwrap() error

Unwrap returns the underlying error.

type ID

type ID struct {
	// contains filtered or unexported fields
}

ID represents a unique identifier for domain entities.

func IDFromString

func IDFromString(s string) (ID, error)

IDFromString creates an ID from a string.

func IDFromUUID

func IDFromUUID(u uuid.UUID) ID

IDFromUUID creates an ID from a uuid.UUID.

func MustIDFromString

func MustIDFromString(s string) ID

MustIDFromString creates an ID from a string, panics on error.

func NewID

func NewID() ID

NewID creates a new random ID.

func (ID) Equals

func (id ID) Equals(other ID) bool

Equals checks if two IDs are equal.

func (ID) IsZero

func (id ID) IsZero() bool

IsZero returns true if the ID is empty.

func (ID) MarshalJSON

func (id ID) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*ID) Scan

func (id *ID) Scan(src any) error

Scan implements sql.Scanner for database deserialization.

func (ID) String

func (id ID) String() string

String returns the string representation of the ID.

func (*ID) UnmarshalJSON

func (id *ID) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (ID) Value

func (id ID) Value() (driver.Value, error)

Value implements driver.Valuer for database serialization.

Jump to

Keyboard shortcuts

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