Re: [go-nuts] Question regarding Golang Interfaces and composite struct

2022-04-28 Thread burak serdar
On Thu, Apr 28, 2022 at 9:49 AM Glen D souza wrote: > Consider the following piece of code > > type Dog struct { > } > > type Walker interface { > Walks() > } > > func (d *Dog) Walks() { > > } > > func CheckWalker(w Walker) { > > } > > func main() { > dog := Dog{} > CheckWalker(dog) -

[go-nuts] Question regarding Golang Interfaces and composite struct

2022-04-28 Thread Glen D souza
Consider the following piece of code type Dog struct { } type Walker interface { Walks() } func (d *Dog) Walks() { } func CheckWalker(w Walker) { } func main() { dog := Dog{} CheckWalker(dog) -> cannot use dog (variable of type Dog) as Walker value in argument to CheckWalker: Do