为什么SetAge()方法不能正确设置年龄?

I'm experimenting with GoLang and interfaces and struct inheritence.

I've created a set of structures with the idea that I can keep common methods and values in a core structure an then just inherit this and add extra values as appropriate:

type NamedThing interface {
    GetName() string
    GetAge()  int
    SetAge(age int)
}

type BaseThing struct {
   name string
   age  int
}

func (t BaseThing) GetName() string {
   return t.name
}

func (t BaseThing) GetAge() int {
   return t.age
}

func (t BaseThing) SetAge(age int) {
   t.age = age
}

type Person struct {
   BaseThing
}

func main() {
    p := Person{}
    p.BaseThing.name = "fred"
    p.BaseThing.age = 21
    fmt.Println(p)
    p.SetAge(35)
    fmt.Println(p)
}

Which you can also find here in the go playground:

https://play.golang.org/p/OxzuaQkafj

However when I run the main method, the age remains as "21" and isn't updated by the SetAge() method.

I'm trying to understand why this is and what I'd need to do to make SetAge work correctly.

Your function receiver's are value types, so they are copied into your function scope. To affect your received type past the lifetime of the function your receiver should be a pointer to your type. See below.

type NamedThing interface {
    GetName() string
    GetAge()  int
    SetAge(age int)
}

type BaseThing struct {
   name string
   age  int
}

func (t *BaseThing) GetName() string {
   return t.name
}

func (t *BaseThing) GetAge() int {
   return t.age
}

func (t *BaseThing) SetAge(age int) {
   t.age = age
}

type Person struct {
   BaseThing
}

func main() {
    p := Person{}
    p.BaseThing.name = "fred"
    p.BaseThing.age = 21
    fmt.Println(p)
    p.SetAge(35)
    fmt.Println(p)
}