3 ms·
> No, this problem is faced by anyone that needs to read code code written by other developers. No, it's not a problem for code readers. If you see a file bein
by mseepgood 13y ago
> No, this problem is faced by anyone that needs to read code code written by other developers.
No, it's not a problem for code readers. If you see a file being passed as an argument to a function which expects a Reader, you know that it implements Reader. Otherwise it wouldn't have compiled.
- pjmlp 13y agoHow to answer the question "Given type X what are ALL interfaces that it implements from the overall code"?
- NateDad 13y agoFirst 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.
- pjmlp 13y agoBecause 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?
- NateDad 13y agoYou 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.