News for hackers. Stuff that matters.
Re:Interfaces in Go make it hard to navigate code by pjmlp on Monday May 27, 2013 @07:01AM (#5774185)
How to answer the question "Given type X what are ALL interfaces that it implements from the overall code"?
Re:Interfaces in Go make it hard to navigate code by NateDad on Monday May 27, 2013 @07:09AM (#5774205)
First off, why do you need to know? The whole point is that interfaces are in no way tied to the things that implement them.

Second, you can search for the function definition(s) that define the interface. Search for Write(p []byte) if you're looking for Writers.

If you're in control of the interface, you can just modify it slightly and see what breaks.

Re:Interfaces in Go make it hard to navigate code by NateDad on Monday May 27, 2013 @07:28AM (#5774245)
You still haven't said why you would need to find all implementations of an interface. "Because I'm new to the company" is not a reason.

The thing about interfaces is that the function that takes the interface is the thing that defines how it is used. The implementation of the type that implements the interface is irrelevant.

log.Logger writes logging output to an io.Writer. It doesn't care what the implementation of any particular writer is... the writer could be sending data across the network, it could be writing it to the console, could be writing to a file... doesn't matter. Logger just calls Write() and merrily goes about its business. Trying to look up all the implementations of the io.Writer interface is not useful when looking at log.Logger. They're mostly unrelated.

Now, if you're trying to figure out how to do some specific thing, like log to a Windows named pipe, then you'd want to start looking around your named pipe library to see if it implements Write().... which it almost certainly does.

Re:Interfaces in Go make it hard to navigate code by pjmlp on Monday May 27, 2013 @07:22AM (#5774230)
Because in the enterprise world we have these boring projects with 60+ developers scattered around the world, high rotation of developers and new guys need to be able to jump into the code of several megabytes of text?