Can someone explain why this doesn't work? It works if DoMove
takes a struct instead of a pointer.
package main
import (
"fmt"
)
type Vehicle interface {
Move()
}
type Car interface {
Vehicle
Wheels() int
}
type car struct {}
func (f car) Move() { fmt.Println("Moving...") }
func (f car) Colour() int { return 4 }
func DoMove(v *Vehicle) {
v.Move()
}
func main() {
f := car{}
DoMove(&f)
}