Hacker News new | ask | show | jobs
by thirsteh 4715 days ago
Okay, it might not be totally obvious, but File implements io.Reader and io.Writer (you can tell by the Read and Write methods.) Therefore, you can use all the functions that take an io.Reader or io.Writer, i.e. all the functions in http://golang.org/pkg/io/ and http://golang.org/pkg/io/ioutil/. It also implements io.Closer (Close() method), which you can use to flush and close the file when you're done.

It would probably be helpful if there was some kind of auto-generated list of the known (or at least stdlib) interfaces a given type implements, even if you don't actively declare it (like Java 'implements'.)