Structs in Go
Go supports user-defined types called structs, which allow you to group together related data into a single object.
type Person struct {
Name string
Age int
}
var p Person = Person{"John", 30} // declare and initialize a Person struct
fmt.Println(p.Name) // prints "John"
No comments:
Post a Comment