domain

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUserNotFound = errors.New("user not found")

Functions

This section is empty.

Types

type User

type User struct {
	ID    string `json:"id"`
	Name  string `json:"name"`
	Email string `json:"email"`
}

type UserRepository

type UserRepository interface {
	FindAll() []*User
	FindByID(id string) (*User, error)
	Create(u *User) *User
	Update(id string, u *User) (*User, error)
	Delete(id string) error
}

UserRepository is the port — domain defines what it needs.

type UserService

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

UserService contains business logic. Depends only on interfaces.

func NewUserService

func NewUserService(repo UserRepository) *UserService

func (*UserService) Create

func (s *UserService) Create(u *User) *User

func (*UserService) Delete

func (s *UserService) Delete(id string) error

func (*UserService) Get

func (s *UserService) Get(id string) (*User, error)

func (*UserService) List

func (s *UserService) List() []*User

func (*UserService) Update

func (s *UserService) Update(id string, u *User) (*User, error)

Jump to

Keyboard shortcuts

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