This is the third in my series of best books to learn Go in 2023. Read my conclusion or check out the other posts in this series:
- Go Programming Language for Dummies by Wei-Meng Lee
- Go Programming In Easy Steps by Mike McGrath
- Learning Go by Jon Bodner (this post)
- Beginning Go Programming by Rumeel Hussain and Maryam Zulfiqar
- Learning Go Programming by Shubhangi Agarwal
- Go For Beginners by Edward Thornton
- Learn Go With Pocket-Sized Projects by Aliénor Latour, Pascal Bertrand, and Donia Chaiehloudj
- Go Fundamentals by Mark Bates and Cory LaNou
- The Go Programming Language by Alan Donovan and Brian Kernighan
- Get Programming with Go by Nathan Youngman and Roger Peppé
- For the Love of Go by John Arundel
Prefer to watch this review?
Publication Details
Learning Go: An Idiomatic Approach to Real-World Go Programming 1st edition; by Jon Bodner, 375 pages. Published April 6, 2021 (third release of 1st edition published May 13, 2022) by O’Reilly Media.
Audience
From the preface of the book (page xiv), “this book is targeted at developers who are looking to pick up a second (or fifth) language. The focus is on people who are new to Go.”
A further emphasis is made on those who wish to learn to write idiomatic Go. “While you can write Go code that looks like Java or Python, you’re going to be unhappy with the result and wonder what all the fuss is about.” This should be no surprise, given the book’s subtitle, An Idiomatic Approach to Real-World Go Programming.
If you are brand new to programming entirely, this may not be the best book for you, as it does assume familiarity with basic programming concepts, including version control, concurrency, and abstraction.
Narrative Style
I’ve always been a fan of the O’Reilly books. Probably the first one I read was the famous Learning Perl, (although the second edition, in my case).
So reading another O’Reilly book just feels comfortable. Like going home for Christmas.
Author Jon Bodner’s (perhaps with the help of O’Reilly’s editorial staff) has done a great job of writing a book that’s easy to read, direct, and not dry and dull.
The preface hits the nail on the head when it says “the focus for Learning Go isn’t just how to write programs in Go; it’s how to write Go idiomatically.” I see that theme throughout, as Bodner is consistently pointing out what is considered the “more correct” way of doing things, without sounding dogmatic. For example, while talking about numeric literals,
Go allows you to put underscores in the middle of your (integer) literal. This allows you to, for example, group by thousands in base ten (1_234). … You could put an underscore between every digit in your literal (1_2_3_4), but don’t. Use them to improve readability.
Content
I’m impressed by how thoroughly this book covers the topics of Go. Whereas the last two books I reviewed skimmed over huge swaths of the language, notably not even mentionining the common numeric types, this book is complete. Arguably to a fault—it spends two full pages talking about the complex64
and complex128
types! 😂
It also goes into detail on many of the common “gotchas” that new Go developers experience. Page 32 talks about Unused Variables, for example:
Another Go requirement is that every declared local variable must be read. It is a compile-time error to declare a local variable and not read its value.
This type of detail is essential for newcomers to the language (as evidenced by the repetition by which a variant of this is asked on StackOverflow), yet it’s often overlooked by authors and tutorials.
One challenge when writing a book on a technical topic is the chicken-and-egg problem when presenting topics that depend on and build on each other. This book handles this problem gracefully, and in my preferred way, by introducing the dependent topic, but just enough to understand the topic at hand, then referring you to the later (or sometimes earlier) section of the book where the depedent topic is covered in detail.
This book covers all of the vital topics, including Go modules, how to write tests using the testing
package, and even Generics! It also covers a number of important peripheral topics, such as the pkg.go.dev web site, best practices for senitnel errors, and even admonishes the reader to read Effective Go, and the Code Review Comments section of the Go wiki, two resources I consistently point newcomers to as well.
I also learned a few things from this book, which is refreshing, considering I’ve already been using Go as my daily programming language for several years.
Accuracy
I haven’t found any outright errors in this book. There are a few outdated bits, but impressively, some of them are even noted in the book itself! While the first rlease of this book was originally published on March 2, 2021, I got a copy of the third release, published on May 13, 2022, which includes a few notes where information in the book is now outdated.
Physical Charactaristics
If you’ve ever read an O’Reilly book, you already know what to expect here. A high-quality, no-frills, black and white production. Easy to read, with clear section headings and break points, but without any “fluff” to get in the way. The sparse graphics are simple monochromatic icons that draw attention to specific tips, notes, and cautionary text.
Conclusion
I’m a fan.
I’m only half way through my stack of 6 Go books, but I like this one. Even as a long-time Go user, this is a good read.
The only reason I would suggest avoiding this book is if you are an absolute beginner to computer programming.