Go interfaces communicate intent

1 · risk danger olson · Sept. 4, 2014, midnight
Interfaces are one of my favorite features of Go. When used properly in arguments, they tell you what a function is going to do with your object. go // from io func Copy(dst Writer, src Reader) (written int64, err error) Right away, you know Copy() is going to call dst.Write() and src.Read(). Interfaces in return types tell you what you can and should do with the object. go // from os/exec func (c *Cmd) StdoutPipe() (io.ReadCloser, error) { It’s unclear what type of object StdoutPipe() is ret...