code:
package main
import "fmt"
type implementation struct {
d []int
}
func (impl *implementation) getData() interface{} {
return impl.d
}
type phase struct{}
type data interface {
getData() interface{}
}
func MakeIntDataPhase() *phase {
return &phase{}
}
func (p *phase) run(population []data) []data {
return nil
}
func main() {
var population []implementation
MyPhase := MakeIntDataPhase()
fmt.Println(MyPhase.run(population))
}
When running following code in playground I got following error: prog.go:30:25: cannot use population (type []implementation) as type []data in argument to MyPhase.run
I am new to golang and I don't understand why is this happening?
Struct implementation
implements method getData()
from data
interface. Isn't it enough to use a slice of implementation
in run
method?
Where my reasoning is wrong?