Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type User ¶
type User struct {
ID int `json:"id"`
FirstName string `json:"first_name"`
MiddleInitial string `json:"middle_initial,omitempty"`
LastName string `json:"last_name"`
CreatedAt *time.Time `json:"-"`
UpdatedAt *time.Time `json:"-"`
}
User represents a user of the system
type UserStorage ¶
UserStorage ...
var UserDB UserStorage
UserDB is a package level variable acting as an in-memory user database
func (*UserStorage) AddUser ¶
func (us *UserStorage) AddUser(u User) (*User, error)
AddUser will add a user if it doesn't already exist or return an error
func (UserStorage) GetUserByID ¶
func (us UserStorage) GetUserByID(id int) (*User, error)
GetUserByID returns the user record matching privided ID
func (UserStorage) GetUserByName ¶
func (us UserStorage) GetUserByName(firstName string, lastName string) (*User, error)
GetUserByName will return the first user matching firstName and LastName This may not work in the real world since names are not unique
func (UserStorage) GetUsers ¶
func (us UserStorage) GetUsers() []User
GetUsers returns the slice of all users
func (*UserStorage) UpdateUser ¶
func (us *UserStorage) UpdateUser(u User) error
UpdateUser will overwrite current user record with new data
Click to show internal directories.
Click to hide internal directories.