Honestly, I don't see how this book can be called "Mastering Concurrency...". There is a racing condition in its first example, and it goes worse from there.
The author does not distinguish between the Go language from its implementation. While discussing goroutines, we are left with the impression that specifics of Go Compiler 1.3/1.4 implementation of goroutines are part of the language semantics. Hence, some examples in the first chapter will deadlock or produce errors when compiled and ran with gccgo, or even Go Compiler 1.5. Note that the Go language semantics hasn't changed with those compilers. The examples are just not correct concurrent programs. This is exactly the opposite of what one would expect from a concurrency book.
The concept of closing a channel is introduced with the sentence: "It's critical that all channels are closed at some point or our application will hit a deadlock." Which can be true in some cases, but it is nonsense as a general rule, and also does not apply in the authors' actual example.
And so on.
Overall, the text is chaotic and full of errors. Concepts are introduced randomly, and seldom well explained. I regret buying this book.
There are really countless pointless reviews for this book on Amazon and GoodReads. It's disheartening to see so many without moderation. The book did explain Concurrency in Go without causing mass hysteria. I didn't know much about Go but quickly discovered it's rather straight forward approach, if anything you might complain that the author gives you so many different points to go off of, or that the UML diagrams in the book are just functional and usable. There are just a few things that I love to see in a book: 1. Usable code, and 2. Diagrams that further visually explain concepts. The portion on shared memory was priceless and something I've seen many programs just look past because of the abundance of memory that's now afforded to powerful servers, this isn't an excuse to get lazy with utilizing resources. I felt the book did an excellent job of explaining concepts, putting them into practice, and while it wasn't all eye candy the core concepts were spot on.
So yes I would recommend this book if you're serious about learning, and there are no books that I purchase where I would take the code and place it into a production environment. That is just asking for trouble, these books are designed to help you learn new programming languages, the logic however is on your part.
Little is being said about concurrency. Examples are full of cruft and are usually full of errors. Add to that numerous editorial mistakes such as writing normal paragraphs in monospace.
It's really hard to write a book about an evolving programming language, such as Go. Tools and libraries are constantly changing, and best practices are being developed as the community grows. As far as books to cover Go *beyond* a basic introduction, there are very few for sure, but this one you'll want to own.
Nathan focused on one of Go's most powerful features - concurrency: go routines and channels. I found the book overall highly informative and well written. It took me a few passes of the book to fully extract all the points, and I think that others coming from languages which don't lend themselves well to parallelism - such as Python, Perl and others - will have a similar experience. Programming concurrently requires you to think about problems in a very different way, and this book does an excellent job of building up the concepts and methods which are going to be important to a successful developer.
What does it cover, at a high level? - goroutines - channels (buffered, unbuffered) - cross-channel communication techniques and synchronization methods - comparison of Go synchronization to CSP (Communicating Sequential Processes) and actor models (ex. Erlang) - design patterns for concurrency - deadlocks and race conditions and how to avoid (and detect) them
What I highly appreciated about the book in particular: - lots of visual examples to drive concepts of how concurrent go routines work - touches on a *lot* of useful third-party tools and libraries for the examples (Gorilla, Heka, Memcached, MongoDB, Redis, CouchDB, Cassandra, Couchbase, fsnotify and many, many others - even Google App Engine) - analyzation techniques and touches interesting tools/apps for Go (ex. pprof, GNUplot, Heka)
What I'd like to see / improve about the book: - *all* the code examples to be able to re-produce any part of the work in the book (ex. I cannot find the GNUplot scripts anywhere..) - an acronym or definitions section for easy reference (ex. CSP, C10K, "actor", etc.) - the author should be more vocal in the community.. talks, blogs and/or online presence in general
A basic summary of the book is as follows: Chapter 1 - An Introduction to Concurrency in Go + introduces goroutines and channels + compares how Go handles concurrency compared to other languages Chapter 2 - Understanding the Concurrency Model + talks about resource allocation, channels and ‘channels of channels’ + explains how Go manages concurrency internally with excellent visualization of concurrent routines working together Chapter 3 - Developing a Concurrent Strategy + discusses how to plan out solving application problems with concurrency + introduces some third-party tools Chapter 4 - Data Integrity in an Application + looks at issues with concurrency and data structures and how Go handles state + discusses how to synchronize data between different machines Chapter 5 - Locks, Blocks, and Better Channels + blocking methods, building on the concepts from the prior chapters + discusses how you can avoid dead locks with Go Chapter 6 - C10K - A Non-blocking Web Server in Go + concrete example of creating a web server with Go concurrency using everything learned in the prior chapters plus a database (MySQL) Chapter 7 - Performance and Scalability + focuses on optimizing your concurrent Go code + builds on the web server created from Chapter 6 Chapter 8 - Concurrent Application Architecture + focuses on when and where to implement concurrent patterns + how to take advantage of advanced hardware and keeps data consistent Chapter 9 - Logging and Testing Concurrency in Go + OS-specific methods for developing, tested and deploying your app Chapter 10 - Advanced Concurrency and Best Practices + looks at complicated and advanced techniques for concurrency + discusses various testing and documentation methods
I liked Go programming language, however I was a bit skeptical of its use in real projects (mainly web projects), this book opened my mind and showed me all the possibilities and power of Go language. Now, I decided that it is a good idea to migrate some services and projects to Go Language :) Recommended.
I highly recommend author to run/debug all examples in his own machine, review basics of channels and goroutines, stick to the subject and rewrite the book. For the reader, sadly the book is not structured well, moving off the topic frequently and full of errors. Its not worth the time.