Get the latest tech news

Interface Upgrades in Go (2014)


November 5, 2014 Much has been written about Go’s interfaces. They’re one of the language features I like best, providing a very pragmatic trade-off between the complexity of more powerful type systems and the anarchy of duck typing.

You’ll find that many of Go’s built-in buffer types (e.g., those in package bufio, as well as bytes.Buffer and strings.Reader) also implement io.ReaderFrom and io.WriterTo, allowing many common io pipelines to be performed with less byte movement than one might expect. Making use of these more efficient system calls often requires careful application-level bookkeeping and invasive architectural changes, and as a result only high-performance HTTP servers typically use them. The Go standard library has automatically, and in all likelihood without you knowing, upgraded every io.Copy from a file to a TCP socket to use a system call that was previously reserved for high-performance proxies, just because it could.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Interface Upgrades

Interface Upgrades