On Sunday, February 24, 2019 at 4:31:10 PM UTC-5, Deomid Ryabkov wrote:
>
> Why can't Go resolve methods declared on the pointer receiver of the 
> destination type?
>
 
Because that  is not how the language was designed. (I'm too busy to look 
up the spec here, but it is in there.)

>
> consider:
>
> [SNIP]
>
> (playground link: https://play.golang.org/p/v0f9pYaTJAa )
>
> it fails to compile with "prog.go:25:23: f2.GetBar undefined (type Foo has 
> no field or method GetBar)" but it's not clear to me, why Foo doesn't get 
> pointer methods from *foo.
>
>  
You could try using an embedded type to have Foo "inherit" methods from 
*foo, like this - https://play.golang.org/p/WvNj5GUjsxe. 

Good Luck

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to