package user import "errors" const DeletedUserName = "Deleted user" const ( LastRoleOwner = "Owner" LastRoleAdmin = "Admin" ) var ErrLastOwner = errors.New("last owner") var ErrLastAdmin = errors.New("last administrator") var ErrAccountNotDeletable = errors.New("account not deletable") type LastAdminError struct { Role string } func (e LastAdminError) Error() string { if e.Role == LastRoleOwner { return ErrLastOwner.Error() } return ErrLastAdmin.Error() } func (e LastAdminError) Is(target error) bool { if target == ErrLastAdmin { return true } return target == ErrLastOwner && e.Role == LastRoleOwner } type Erasure struct { UserID uint32 GuardRoleIDs []uint32 AvatarImageID *uint32 } type Eraser interface { Erase(erasure Erasure) error }