Final Thoughts

Our code is riddled with error checking, even more than usual for Go. Working with sockets feels, and is, lower level than working with HTTP, gRPC, and other methods. If you have a choice, pick a high-level established protocol—it’ll save you a lot of work. But in some cases, mostly when you need the extra performance, you can consider working with sockets.

The nice thing about Go is that it makes working with sockets easy. Once you establish a connection, you switch to working with io.Reader and io.Writer—a lot of built-in functions accept them.

L. Peter Deutsch and others at Sun Microsystems wrote a list of false assumptions, called “Fallacies of distributed computing”:

  1. The network is reliable
  2. Latency is zero
  3. Bandwidth is infinite ...

Get Effective Go Recipes now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.