Documentation ¶
Index ¶
- type Account
- type AccountRepository
- type AccountService
- func (s *AccountService) CreateAccount(a *Account) error
- func (s *AccountService) DeleteAccount(id int) error
- func (s *AccountService) GetAccount(id int) (*Account, error)
- func (s *AccountService) GetAccountUppercase(id int) (*Account, error)
- func (s *AccountService) ListAccounts() ([]*Account, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountRepository ¶
type AccountRepository interface { GetAccount(id int) (*Account, error) ListAccounts() ([]*Account, error) CreateAccount(a *Account) error DeleteAccount(id int) error }
AccountService makes use of the AccountRepository interface to interact with the storage implentation. The actual implementation can be written to use an RDB, for example, or could also be mocked out for unit testing purposes.
type AccountService ¶
type AccountService struct {
// contains filtered or unexported fields
}
func NewAccountService ¶
func NewAccountService(r AccountRepository) AccountService
Takes an AccountRepository implementation and returns an AccountService.
func (*AccountService) CreateAccount ¶
func (s *AccountService) CreateAccount(a *Account) error
Creates a new account.
func (*AccountService) DeleteAccount ¶
func (s *AccountService) DeleteAccount(id int) error
Deletes an account by ID.
func (*AccountService) GetAccount ¶
func (s *AccountService) GetAccount(id int) (*Account, error)
Gets an account by ID.
func (*AccountService) GetAccountUppercase ¶
func (s *AccountService) GetAccountUppercase(id int) (*Account, error)
Gets an account from the repository and coverts all of its fields to uppercase before returning. As converting to uppercase is not infrastructure dependent, the conversion is performed in the service layer.
func (*AccountService) ListAccounts ¶
func (s *AccountService) ListAccounts() ([]*Account, error)
Lists all accounts.
Click to show internal directories.
Click to hide internal directories.