On Fri, May 8, 2020 at 1:34 PM Glen Newton <glen.new...@gmail.com> 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 prefer to do this using reflection and without having to replicate the > same method in all implementations, I have tried using an embedded struct > here[1], but it prints the name of the embedded struct. Is there a way to do > this? > > Why: I have multiple implementations and want to be able to record which > implementation was used.
Perhaps you could use reflect.TypeOf(v).String(). Ian -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAOyqgcURZtc3V_QEcy0PR%2BQvg3Q-rNJ7DqBUyWVNJkz_o9_2%3Dw%40mail.gmail.com.