mirror of
https://github.com/ray-x/navigator.lua
synced 2024-11-19 09:25:30 +00:00
27 lines
356 B
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
|
|
}
|
|
}
|