struct functions golang code example
Example 1: go create new instance of struct
type Person struct {
Name string
}
func main() {
var me Person
me.name = "mattalui"
}
Example 2: go struct methods
type Person struct {
name string
surname string
}
func (p Person) GetName() string {
return p.name
}
func (p Person) GetSurname() string {
return p.surname
}