You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
navigator.lua/playground/go/test/func.go

27 lines
356 B
Go

package test
type Dog struct {
name string
age int
owner string
}
func NewDog(name string, age int) *Dog {
return &Dog{name: name, age: age}
}
// SetOwner
func (d *Dog) SetOwner(owner string) {
d.owner = owner
}
// SetName
func (d *Dog) SetName(name string) {
if d == nil {
d = NewDog(name, 0)
d.name = name
} else {
d.name = name
}
}