Hello all, I am golang beginner. And I have a problem with interfaces. Here is the problem where I have one main package with has an Interface I. and multiple sub packages each implementing interface I. So I have a method which is exactly the same for all sub packages. Is there a way I can implement this method for I.
package main type I interface { F1() GenericMethod() // Is there a way I can implement it on I since its the same in all packages? } package p1 type P1data struct {} (x *P1data) F1() (x *P1data) GenericMethod() package p2 type P2data struct {} (x *P2data) F1() (x *P2data) GenericMethod() under the main package. for each data in sub packages do data.F1 and data.GenericMethod(). Now I don't want to implement GenericMethod for all packages. Since its the same.So can I implement GenericMethod on I (I know this is not possible). But how can do something like this? -Thanks -- 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.