Answer the question
In order to leave comments, you need to log in
How to correctly pass multiple parameters to a function in Golang?
I need to pass many parameters to a function, like this:
user, err := CreateUser(r.Context(), body.Name, body.Email, body.FirstName, body.LastName,
body.Birthday, body.Phone, body.Gender, body.Password, body.Status)
Answer the question
In order to leave comments, you need to log in
In such cases, it is better to pass the structure as a parameter.
Example
type User struct {
Name string
Email string
// все нужные поля далее
}
func CreateUser(r.Context(), user)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question