I am having a problem go interfaces.
Here is my main.go file;
package main
import (
"fmt"
"bitbucket.org/xyz/trash/a"
)
// Second -
type Second interface {
Area() float64
}
// Area -
func Area() float64 {
return 2
}
func main() {
r := new(a.Rect)
n := new(Second)
r.F = *n
fmt.Println(r.Area())
}
And my other package, a.go;
package a
// First -
type First interface {
Area() float64
}
// Rect -
type Rect struct {
F First
}
// Area -
func (r Rect) Area() float64 {
return 1
}
I am expecting this line
fmt.Println(r.Area())
to print "2", not "1". What am i missing?
Thanks for your help.