No, this problem is faced by anyone that needs to read code code written by other developers.
If you are faced by a code base written by a team of 30+ developers, good luck trying to find out which types implement which interface.
At least LiteIDE (http://code.google.com/p/liteide) is a possible help that eases the problem.
I can't help to think like what @tomp said. It's really up to the developers to annotate their code and document their Interfaces, specially when using a systems programming language like GO, comments are essential as the code is not as self-explanatory like Python or Ruby. GO provides an excellent tool to generate documentation from internal or external packages: http://golang.org/cmd/godoc/.
There's this great write-up on GO's Interface by Jordan Orelli: http://jordanorelli.tumblr.com/post/32665860244/how-to-use-i...
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.
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.
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.
I disagree. I've even brought this up before in passing on HN:
https://news.ycombinator.com/item?id=5639846
I've written many thousands of lines of Go code and have been using the language for more than a year and I still think the gist of the author's argument is a valid pain point when it comes to Go documentation. I'm now very familiar with the standard Go library, so the problem doesn't impact me as much as it used to, but I do find auto-generated Go documentation for new libraries I haven't yet used to be much harder to get a quick mental overview of than code autogenerated from other languages I've programmed in (including languages which are OO, functional or procedural).
Go is still my favorite language to program in, but I think there is a valid issue here (one that can be fixed with improved tooling)
I had a similar issue on my first toy program with Golang, but found it trivial to check the implemented methods, or assign it and let the compiler blow up if it doesn't fulfill the needs.
type Reader interface {
Read(p []byte) (n int, err error)
}
It should be obvious to any modestly experienced developer that an ordinary file object is likely to satisfy the requirement of having a common Read method.This seems like a basic failure to understand what a Go interface is, nevermind any understanding of the standard library.
For example if I have a Book class that implements a Read method (to mark the book as having been read, for example) then have I just created something which implements io.Reader?
Fair enough, I did say I was only speculating and I've learned something.
It's trying to merge the best parts of two very different worlds. A modest loss of safety is therefore tolerated.
I assure readers that this kind of problem is only faced by beginners. If the author approached the problem from the other direction, i.e. by asking "how do I extract a file's contents?", he would have looked up the documentation for os.File, and found it had a Read() method.
It's not often that you come across an arbitrary interface you have to implement, but aren't sure what to provide. If the documentation doesn't say, then presumably there's an type in the same package that you're meant to use. If not, domain-specific knowledge will help.
In this case it's necessary to have a basic idea of the way the standard library works - which as a beginner, the author doesn't have.
We rarely want a list of all possible types that can implement an interface. There are many different types that implement io.Reader in the standard library, it's not necessary for any particular package to be aware of all others ("slick"). And anyway, your editor might be able to help.
http://golang.org/pkg/os/#File.Read