There is guru (golang.org/x/tools/cmd/guru) which can answer this
question if it really comes up (I rarely feel the need to know all
type implementing flag.Getter).

V.

Am Donnerstag, 27. Oktober 2016 09:11:04 UTC+2 schrieb Arafath M:
>
> Hi,
>
> Using interface is easy in Go. But, while studying an existing code base, 
> it is very difficult to find which types have implementation of a 
> particular interface. The situation will become worse, if there are many 
> interface functions inside an interface definition.
>
> In another languages, it is easy to just search for the class, which 
> implements a particular interface.
>
> For example in Java,
>
> interface Animal {
>    public void eat();
>    public void travel();
> }
>
> public class MammalInt implements Animal {
>
>    public void eat() {
>       System.out.println("Mammal eats");
>    }
>
>    public void travel() {
>       System.out.println("Mammal travels");
>    } 
>
>    public int noOfLegs() {
>       return 0;
>    }
>
>    public static void main(String args[]) {
>       MammalInt m = new MammalInt();
>       m.eat();
>       m.travel();
>    }
> }
>
> By seeing the above line "*public class MammalInt **implements Animal*" one 
> can easily understand that Animal interface is implemented in MammalInt 
>
> In Go, as far as I know, I need to search for all interface functions to 
> find whether a type implements a particular interface or not.
>
> Have anybody else experienced the same? If yes, what is the solution? 
>
> *Note:* Personally I like to write code in Go; all of my recent projects 
> are in Go. I prefer Go than Java.
>
> Sincerely,
> Arafath M
>

-- 
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