[Go, Book Review] Learn Go with Tests by Chris James
Tags: go, testing, begineer
Published: 2024-03-23 09:26:19

*image credit to [Renee French](https://reneefrench.blogspot.com/), the [source is the one of the official Go blog posts](https://go.dev/blog/gopher)

# TL; DR
- The book covers from the very basic concepts of the language to writing complex applications.
- You learn Go interactively by writing tests.
- This book is more than learning Go itself - you learn practical TDD methodology from the author.
- Highly recommended for those who have just started learning Go, or the Software engineering in general.

# Intro - why did I choose this book?

Since my [painful memory of starting my Rust journey](https://dev.to/uponthesky/rust-what-ive-learned-from-reading-the-book-over-the-last-10-months-5f89), I setup my own principle of learning a new programming language: begin with very simple tutorial, and write as many examples as possible before moving on to advanced cases. 

Therefore, I was very fortunate to get to know this amazing book, [Learn Go with Tests](https://quii.gitbook.io/learn-go-with-tests). Right after skimming through [*the tour*](https://go.dev/tour/), I was looking for a material that provides plenty of examples and good practices. The **LGWT** book exactly suits the needs. 

# Good Parts

## 1. Learning features of Go interactively with tests

This book starts from basic concepts of the language such as types, loops, pointers, interfaces, etc. But it also covers several advanced and frequently used concepts such as context and concurrency. The book provides a very good introduction to these difficult topics in general, with actual running examples as tests rather than with abstract words.

I would like to say that learning the language with writing test code is one of the best features of this book. Usually, learning a compile language like C/C++ or Rust requires users to run compilation commands, which usually takes a long time. However, by writing test and run it, you can actually check how a few lines of Go work right away. Even on my old 2017 MacBook Pro with 8GB RAM, running tests usually took around half a second. 

Additionally, almost all the chapters of this book contain tests. Thus, as you read through the book, actually writing and running those tests, you will become much familiar with writing Go.

## 2. Rethinking of software design and tests

In the chapters of building an application, the author constantly bring up the idea of what is a good software design and how you can achieve it with the TDD principle. Except the chapters about Go language features, the book is more like a TDD and software design book with examples written in Go. The author gives his real-life stories from his long time of software engineering careers, and these are what normal software engineers usually face day to day. I was astonished how his stories and claims resonate with my own experience with bad software design and messy test code I had written in the past. If the [TDD book by Kent Back](https://www.amazon.com/Test-Driven-Development-Kent-Beck/dp/0321146530) can be thought of as a manifesto for TDD, this book is more like an anecdote from a senior engineer at the reader’s company. 


# Soso Parts

There are not particularly bad parts. Overall the book is well written and organized. Moreover, Since it is also an [open-source material](https://github.com/quii/learn-go-with-tests), many readers have contributed to the contents of the book(including a few of mine :)). I hope there are more books like this for other languages such as Rust or Python. 

# Conclusion

I highly recommend this book for Go newbies. It covers the language features extensively, and also provides practical code examples that you can run on your machine. You will also learn rigorous principles of writing maintainable and robust software with TDD by reading this book. Even if you’re an experienced Go developer, I am pretty sure you could learn important lessons from this book as well.