Answer the question
In order to leave comments, you need to log in
How to understand what type and structure are in Go?
Hello. I just can’t figure out what type and structure are in Go, how can I understand it easier? When is the best time to use them?
Thank you.
Answer the question
In order to leave comments, you need to log in
Think of it as just a way to group multiple variables into one. Structures should be used where it is more convenient to use a group of variables at once.
For example, we need to pass user data to the function. We can write
func RegisterUser(name string, surname string, age int)
type User struct {
Name string
Surname string
Age int
}
func RegisterUser(user User)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question