I am new with the golang, I am not quite understand why the below demo program could be executed successfully,
type fake interface {
getAge(valueInt int, valStr string) (age int, name string, err error)
}
type Foo struct {
name string
}
func (b *Foo) getAge(valueInt int, valStr string) (age int, retErr error) {
age = valueInt
return age, nil
}
func main() {
inst := &Foo{name:"foo"}
value, _ := inst.getAge(2, "foo")
fmt.Println(value)
}
The interface wants to return three value, but the method getAge
only return two, but it still works. How to understand this behavior in golang?
Thanks!