I come from a python background so for my user registration api's i would make classes that inherit from pyadntic.BaseModel which define my incomming json payload and out going too. In go i was reading code on the internet to see the best practices and I am a bit confused now, so is it okay that if i have a user model like
type User struct {
ID int64
Username string
Email string
Password string
CreatedAt time.Time
UpdatedAt time.Time
}
this which represents a user in the database,
so for my user register route should i have two more structs just like python something like
type UserCreateParams struct {
UserName string `json:"user_name"`
Email string `json:"email" validate:"email"`
Password string `json:"password" validate:"gte=8"`
}
type UserCreateResponse struct {
ID int64 `json:"id"`
Username string `json:"username"`
Email string `json:"email"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
or are there any other ways for a general user oriented backend for modern day applications?
