Jump to ratings and reviews
Rate this book

Ultimate Go Notebook

Rate this book
The Ultimate Go Notebook is the official companion book for the Ardan Labs Ultimate Go class. With this book, you will learn how to write more idiomatic and performant code with a focus on micro-level engineering decisions. This notebook has been designed to provide a reference to everything mentioned in class, as if they were your own personal notes.

Our classes challenge every student to think about what they are doing and why and so does this book.

The first chapter helps you prepare your mind by establishing the mental models and design philosophy for the material you are about to review.
You will learn about the mechanics and semantics behind types, decoupling, error handling, concurrency, and more.
GENERICS! Learn about the new syntax coming to Go 1.18 for writing generic functions and types.
Four chapters on profiling, tracing, and stack traces help you learn critical debugging skills that will make you a more productive Go developer.
The last chapter features the many blog posts that are referenced throughout the book.

If you have taken the class before, this notebook will be an invaluable resource for reminders on the content. If you have never taken the class, there is still tremendous value in this book as it covers more advanced topics not found in other books today.

“If you want to be a better Go developer, code reviewer, designer and architect, this is the book you want.”

When coming from another language, developers often struggle to grasp the fundamentals that make Go useful and unique. This book builds layers of foundational knowledge that will give you a deeper understanding into data semantics, decoupling, concurrency and tooling that is provided with the language.

352 pages

Published January 1, 2021

12 people are currently reading
69 people want to read

About the author

William Kennedy

196 books6 followers
There is more than one author by this name in the Goodreads data base.

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
14 (58%)
4 stars
7 (29%)
3 stars
2 (8%)
2 stars
1 (4%)
1 star
0 (0%)
Displaying 1 - 3 of 3 reviews
Profile Image for Ruslan Bes.
17 reviews1 follower
June 15, 2022
Note: I read this book without participating in the workshop.

#### Chapter 1: Introduction

It's an introduction you don't want to skip. It sets up the scene by throwing at you about a 100 axioms (quotes and statements) about development process in general and Go specifics. What I did is I categorized them mentally into categories "Agree",  "Needs more context", "Don't agree".

A couple examples of axioms:

> I must understand that simplicity is hard to design and complicated to build

This is applicable to software development in general. I "Agreed" to it plus I'd add "and to maintain".

> Efficiency is obtained through algorithms but performance is obtained through data structures and layouts

This turned to be Go-specific. For me it went from "Needs more context" to "Don't agree". I'd add "performance is **also** obtained through data structures and layouts".

#### Chapter 2: Language Mechanics

It's a deep-dive into computer architecture. The main goal is to teach the reader about the word type and explain that in 32-bit acrhitectures the word size is 4 byte and in 64-bit architecture it's 8 bytes. 

This knowledge is immediately used in **2.7 Padding and Alignment**. There is an amazing little example of how you can change the memory usage of your Go program by *reordering fields in struct*.

The second part of that chapter combines two other concepts: passing by value/by reference and how does it affect the stack/heap memory. Right from the start you are trained to understand what happens one level below your code. This is a thing that is missing in other Go tutorials.

#### Chapter 3: Data Structures

Another book would start with syntax of arrays and slices, not this. It starts with *CPU Caches* and *Translation Lookaside Buffers* and ends with a quote *Remember, performance today is about how efficiently I can get data into the processor*. For my current work this information was unnesessary, so I skipped to the second part of this chapter. It starts with **3.5 Iterating Over Collections** and shows how memory is allocated during slice manipulations.

The most important part here is **3.17 Mutations To The Backing Array** - it explains the magic behind creating two slices from the same array and changing one of them. The important thing to know here is that if Go decides it needed to raise the capacity of one of the slices, then you will work with a copy and won't affect the initial array. If it doesn't then you can mutate the original array and may affect the other slice. To avoid this hassle use `copy(slice2, slice1)` but deal with performance hit.

Paragraph **3.21** does a crash-course on UTF-8, runes and codepoints. The main thing to learn here is that iteration over a string is iterating over code points, not per individual bytes.

In the paragraph **3.22** onwards there is a short intro to maps. A nice example is an explanation why `make(map[slice]string)` is invalid code. The key must be hashable. Slices are not.

#### Chapter 4: Decoupling

This chapter is about structs and interfaces. Main takeaways are:

- Structs are grouping the data
- Interfaces are grouping the behavior 
- Methods enable different data to exert the same behavior.

I mentally connected it to the https://en.wikipedia.org/wiki/Duck_test and expressed it in Go:

    type duck interface {
        swim()
        quack()
        look()
    }

#### Chapter 6: Concurrency

The chapter starts with explaining how the OS scheduling work and explaining what is CPU Bound Work vs I/O Bound Work. This is another chapter where you learn how this work one level below your code.

The 10 channel patterns in **6.11** is a ready-to-go cheatsheet. I will check it whenever I need to work with channels in future.

#### Chapter 7: Testing

I knew there is an integrated testing support in Go. The new thing for me was **7.3 Web Call Mocking** - I will keep it in my mind when creating web apps in Go.

#### Chapter 8: Benchmarking

An intro to benchmarks and how to read them. Good to know that benchmarking is also a part of the language binary.

#### Chapter 9: Generics

The best overview of Go generics I've seen so far. Main thing to learn is that generics are type constraints. If you don't need to constrain values, probably you don't need generics.

This chapter is totally out of order here. It would make more sense after "Data structures" or in the end of the book because...

#### Chapter 10: Profiling

...**this** is the chapter that logically continues testing and benchmarking. This is where I started really appreciating the desing of Go because the profiler is also a part of the go binary!

The whole chapter is one big illustrative example showing how one ineffective algorithm allowed escaping values to heap and how the profiler allowed to find it and to figure out what to change. 

#### Chapter 11: Profiling Live Code

This chapter sets up another example and shows that pprof tool can be used in web version. The bonus of the web version is that you get a simple visualization of memory allocations per functions. Again, the fact that you don't need any IDE for that is really impressive.

This chapter also introduces Go Garbage Collector and teaches how to read the output of `GODEBUG=gctrace=1`

#### Chapter 12: Tracing

Again a code example, this time demonstating the most powerful tool. You can generate a trace file and then feed it to the trace tool and you get a web-based analyzer of nearly everything that has happened during the run - a detailed graph with all the info about every thread, what did it do, how much memory and CPU used, what was the heap size, when the GC ran, and for how long. 

#### Chapter 13: Stack Traces / Core Dumps

A small chapter that tries to teach you how to read these two items, nothing specific.

#### Chapter 14: Blog Posts

They cover some deep Computer Architecture things - Pointer mechanics, OS Schedulers and Caches and based on that explain how the Go Garbage Collector works.

### Summary

Advanced book with strong focus on code performance and performance analysis.
Profile Image for Milad.
3 reviews
November 23, 2021
Ultimate Go Notebook is one of the best books that already I read in programming.
Everything describes deeply. And as someone who English is not my first language, this book was easy for me to read. I enjoyed it while reading.
Profile Image for Shoshana.
49 reviews13 followers
Read
October 7, 2022
I took the course over a weekend in college but it was helpful to read this now that I've been writing Go for the last few years.
Displaying 1 - 3 of 3 reviews

Can't find what you're looking for?

Get help and learn more about the design.