Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrUserAlreadyExists = errors.New("user already exists") ErrUserNotFound = errors.New("user not found") )
Functions ¶
This section is empty.
Types ¶
type User ¶
type User struct { ID uint `json:"id"` Username string `json:"username"` Email string `json:"email"` Biography string `json:"biography"` Password string `json:"-"` CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` }
A User is a struct that has an ID, Username, Email, Biography, Password, CreatedAt, and UpdatedAt. @property {uint} ID - The user's ID. @property {string} Username - The username of the user. @property {string} Email - The email address of the user. @property {string} Biography - A short description of the user. @property {string} Password - This is the password of the user. We don't want to return this to the client, so we add the `-` tag to the property. @property CreatedAt - The time the user was created @property UpdatedAt - The time the user was last updated.
type UserService ¶
type UserService interface { CreateNewUser(user *User) error IsExistingUser(username, email string) bool GetUser(user *User) error GetUserById(user *User) error Close() error // contains filtered or unexported methods }
`UserService` is an interface that has a method called `CreateNewUser` that takes a pointer to a `User` and returns an error. @property {error} CreateNewUser - This is the method that will be used to create a new user.
func NewUserService ¶
func NewUserService(psqlInfo string) (UserService, error)
NewUserService create a new instance of UserService returns the newly created UserService instance or ErrInternalServerError if other error is encountered.