Learn Go with Pocket-Size Projects
by Aliénor Latour, Donia Chaiehloudj, and Pascal Bertrand
In November of last year I decided to take part in Manning's manuscript review program as I was already reading one of their MEAP books, Learn Go with Pocket-Sized Projects. Here are my thoughts after reading the entire manuscript...
Target Audience and Goals of the Book
As outlined in the first chapter the book's target audience includes:
- Those with previous experience in other languages who would like to extend their professional skills.
- Teams who are considering Go for their next project by providing a broad and thorough insight of the language.
- Busy people who are looking to complete projects that are both rewarding but doable in a reasonable amount of time.
The author's aim to achieve the following goals:
- Teach using an iterative process with each chapter split into sections that guide you through project implementations on a commit-by-commit basis.
- Provide exemplary and clear examples of industry-level Go code.
- Leave the reader inspired and with enough knowledge to go on to write excellent Go code themselves.
Structure
The book is comprised of 12 chapters, each one walking the reader through a single project although the final chapter technically covers two subjects and is designed to round off the book.
The kinds of projects you will develop include:
- A 3-level logging library with a stable, exported API.
- A CLI money converter app
- A concurrent maze solver
- A gRCP web service and client.
Each chapter follows a similar structure:
- Introductory text written in a narrative style often providing historical or cultural context to the problem at hand.
- An outline of the projects Requirements and Limitations.
- A step by step walkthrough of the project's implementation
- A summary section detailing the salient points.
I don't have enough space in this article to talk about every project in the book but I'll briefly cover two of them.
Bookworm's digest (chapter 3)
If you're like me and you love reading books, then anything bookworm related is probably interesting to you! In this chapter you'll load virtual bookshelves stored in JSON files and use Go to read, sort and analyse the data.
This chapter covers the following:
- Use of maps as an in-memory storage
- Use of deferred functions and their stacked execution
- Decoding JSON files into Go structs
- Sorting slices with custom comparators as well as implementing
sort.Interface{}
Concurrent maze solver (chapter 9)
This chapter introduces you to the world of maze solving.
This chapter covers the following:
- Use of the
image/png
library to load and write mazes to disk. - How to spin up many goroutines to search paths simultaneously.
- How to record the paths searched and colour them on the PNG.
- How to synchronise goroutines using channels and waitgroups.
Do the authors achieve their goals?
In my opinion the answer to this is a clear yes.
Goal one: Iterative process
Each chapter is split into sections with each section building on the previous. The chapters themselves are also sufficiently organised by difficulty.
The authors take a bottom up approach, for each project they start with the basics from initializing the module, defining the project specification, thinking through the design choices and finally onto implementation.
The reader is encouraged to commit their work to source control before any major additions.
The authors go to great lengths to explain their thought processes. This is very important from the readers perspective because it allows you to think about 'why' something should be done and not just 'how'.
Goal two: Production level code
Testing is a primary concern throughout the book and encouraged at every step.
The authors stress the importance of thinking through design choices carefully, not only their impact in the moment but also into the future.
Although anti-patterns are used to demonstrate less than ideal code, the authors do a good job of explaining the shortcomings and then go on to demonstrate a preferred implementation.
Goal three: Projects scaled for busy people
As is addressed in the book's appendix, several of the chapters have you write projects that rely on in-memory databases primarily to keep the projects sized reasonably (doable in a day or two). The authors stated clearly both in the chapters and in the appendix that this is normally an unacceptable solution and would not be suitable for production code.
Conclusion
I think that Learn Go with Pocket-Sized Projects is a beautifully written book that serves its stated goals.
The book does a good job of presenting the strength and flexibility of Go, offering projects that deliver a broad coverage of the language.
The writing style is a mixture of conversational, humorous and terse but for the most part explanations are straightforward and to the point.
I wouldn't recommend this book as a first read in Go for a newcomer, better a second or third book. Certainly I would recommend it to anyone looking for a book for further their knowledge in Go best practices and project design.
Further Notes:
- The downloadable code that accompanies the book was very well organised!
Subscribe to this blog's RSS feed