Re: [go-nuts] Get name of struct implementing interface using interface method, reflection

2020-05-08 Thread Marcin Romaszewicz
Go isn't polymorphic, whenever your String() function is called, it's on BaseFoo, you have to do it like this: https://play.golang.org/p/69rw0jRPalz On Fri, May 8, 2020 at 1:43 PM Glen Newton wrote: > Thanks! > > Oh no, when I try that here: https://play.golang.org/p/RV-S4MJWYUi > Did not work:

Re: [go-nuts] Get name of struct implementing interface using interface method, reflection

2020-05-08 Thread Glen Newton
Thanks! Oh no, when I try that here: https://play.golang.org/p/RV-S4MJWYUi Did not work: similar results: instead of: BaseFoo BaseFoo BaseFoo BaseFoo now I get: main.BaseFoo main.BaseFoo main.BaseFoo main.BaseFoo Other suggestions? :-) Thanks, Glen -- You received this message because you a

Re: [go-nuts] Get name of struct implementing interface using interface method, reflection

2020-05-08 Thread Ian Lance Taylor
On Fri, May 8, 2020 at 1:34 PM Glen Newton wrote: > > I would like to get the name of the struct implementing an interface (using a > method in the interface). I could just have the MyInterface.StructName() > method in each implementing struct which just did a return "myname" but I > would pref

[go-nuts] Get name of struct implementing interface using interface method, reflection

2020-05-08 Thread Glen Newton
Hello, I would like to get the name of the struct implementing an interface (using a method in the interface). I could just have the MyInterface.StructName() method in each implementing struct which just did a return "myname" but I would prefer to do this using reflection and without having to