liveBook · Manning

What you will learn in Learn Go with Pocket-Sized Projects

by Aliénor Latour, Donia Chaiehloudj, and Pascal Bertrand
Foreword by Ron Evans

Chapter by chapter

Chapter 1: Meet Go

1.1 What is Go? · 1.2 Why you should learn Go · 1.2.1 How and where Go can help you · 1.2.2 Where Go cannot help you · 1.2.3 Comparison with commonly used languages · 1.3 Why pocket-sized projects? · 1.3.1 What you’ll know after reading the book (and writing the code) · 1.4 Summary

What you learn in chapter 1 →

Chapter 2: Hello, earth! Extend your hello, world

2.1 Any travel begins at home · 2.1.1 Our first program: main.go · 2.1.2 Let’s test with the Example function · 2.1.3 Calling the greet function · 2.1.4 Testing a specific function with the testing package · 2.2 Are you a polyglot? · 2.2.1 Parlez-vous français? The switch angle · 2.2.2 Adapt the test with Test functions · 2.3 Supporting more languages with a phrasebook · 2.3.1 Introducing the Go map hash table · 2.3.2 Writing a table-driven test · 2.4 Using the flag package to read the user’s language · 2.4.1 Add a flag · 2.4.2 Test the command-line interface · 2.5 Side quests · 2.6 Summary

What you learn in chapter 2 →

Chapter 3: A bookworm’s digest: Playing with loops and maps

3.1 Loading the JSON data · 3.1.1 Defining a JSON example · 3.1.2 Opening a file · 3.1.3 Parse the JSON · 3.1.4 Test it · 3.2 Finding books that bookworms have in common · 3.2.1 Count the books · 3.2.2 Keeping higher occurrences · 3.2.3 Determinism · 3.3 Print · 3.4 Improvements · 3.4.1 Implement sort.Interface · 3.4.2 Exercise: Reading recommendations · 3.4.3 Using bufio to open a file · 3.5 Summary

What you learn in chapter 3 →

Chapter 4: A log story: Creating a library

4.1 Defining the API · 4.1.1 Package summary · 4.1.2 Exporting the supported levels · 4.1.3 Object-oriented Go: “GoOOP”? · 4.1.4 The New() function · 4.1.5 What about testing? · 4.1.6 Documenting code · 4.2 Implementing the exported methods · 4.2.1 Default implementation · 4.2.2 Interfacing · 4.2.3 Refactoring · 4.3 The functional options pattern · 4.3.1 Creating configurations · 4.3.2 Testing our example · 4.4 Additional functionalities · 4.4.1 Logging the log level · 4.4.2 Exposing the generic logging function · 4.5 Logging: Best practices · 4.6 Summary

What you learn in chapter 4 →

Chapter 5: Gordle: Play a word game in your terminal

5.1 Basic main version · 5.1.1 Mini main · 5.1.2 Read player’s input · 5.1.3 Isolate the check · 5.1.4 Check for victory · 5.2 Providing feedback · 5.2.1 Define character status · 5.2.2 Checking a guess against the solution · 5.3 Corpus · 5.3.1 Create a list of words · 5.3.2 Read the corpus · 5.3.3 Pick a word · 5.3.4 Let’s play! · 5.4 The limit of runes · 5.5 Conclusion · 5.6 Summary

What you learn in chapter 5 →

Chapter 6: Money converter: CLI around an HTTP call

6.1 Business definitions · 6.1.1 Converting money · 6.2 Representing money · 6.2.1 Floating-point numbers · 6.2.2 Back to money · 6.2.3 Floating-point number operations · 6.2.4 Implementing decimals · 6.2.5 Currency value object · 6.2.6 NewAmount · 6.3 Applying conversion logic · 6.3.1 Applying an exchange rate · 6.3.2 Validating the result · 6.4 Writing the CLI · 6.4.1 Flags and arguments · 6.4.2 Parse into business types · 6.4.3 Stringer · 6.4.4 Convert · 6.5 Calling the bank · 6.5.1 Dependency injection: Theory · 6.5.2 ECB package · 6.5.3 HTTP call: Easy version · 6.5.4 Parse the response · 6.5.5 Integration in the money package · 6.5.6 Dependency injection in main · 6.5.7 Sharing the executable · 6.6 Making improvements · 6.6.1 Caching · 6.6.2 Timeout · 6.6.3 Alternative tree · 6.7 Summary

What you learn in chapter 6 →

Chapter 7: Caching with generics

7.1 A naive cache · 7.1.1 Introduction to generics · 7.1.2 Project initialization · 7.1.3 Implementation · 7.2 Introducing goroutines · 7.2.1 What’s a goroutine? · 7.2.2 How to launch a goroutine · 7.2.3 Using channels to communicate that a goroutine has ended · 7.2.4 Running goroutines and having a synchronization point · 7.3 A more thread-safe cache · 7.3.1 Using goroutines · 7.3.2 Using t.Parallel() · 7.3.3 Using go test -race . · 7.3.4 Add a mutex · 7.4 Possible improvements · 7.4.1 Adding time to live · 7.4.2 Add a maximum number of items in the cache · 7.5 Common mistakes · 7.5.1 When to use channels in a concurrency situation · 7.5.2 Concurrency effect of a workload type · 7.5.3 Finish your goroutines · 7.6 Summary

What you learn in chapter 7 →

Chapter 8: Gordle as a service

8.1 Empty shell for the new service · 8.1.1 Server, service, web service, endpoints, and HTTP handlers · 8.1.2 Let’s code · 8.2 Adding endpoints · 8.2.1 Create a new game · 8.2.2 Get the game status · 8.2.3 Guess · 8.3 Domain objects · 8.3.1 Domain types · 8.3.2 API adapters · 8.4 Repository · 8.4.1 In-memory database · 8.4.2 Simplest repository · 8.4.3 Service-level dependency · 8.4.4 Add a mutex to the repository · 8.5 Adapting the Gordle library · 8.5.1 API of the library · 8.5.2 Usage in the endpoints · 8.6 Security notions and improvements · 8.6.1 Limiting the number of requests served at a time · 8.6.2 User authentication · 8.6.3 Logging · 8.6.4 Error formatting · 8.6.5 Decode query parameters · 8.7 Summary

What you learn in chapter 8 →

Chapter 9: Concurrent maze solver

9.1 Maze generation · 9.1.1 What is an image? · 9.1.2 Maze constraints · 9.2 Maze solver · 9.2.1 Setup · 9.2.2 Loading the maze image · 9.2.3 Add the solver · 9.3 Let’s go exploring! · 9.3.1 Finding the entrance · 9.3.2 Communicating new possible paths · 9.3.3 Recording the explored path · 9.3.4 Waiting for unexplored paths and starting a goroutine · 9.3.5 Stop listening, we found it: Short version · 9.3.6 Testing one goroutine’s logic · 9.4 Show the result · 9.5 Notify when the treasure is found · 9.5.1 Keep track of all the goroutines · 9.5.2 Send a quit signal · 9.6 Visualization · 9.6.1 Overcome the loop constraint · 9.6.2 Animate the exploration · 9.7 Summary

What you learn in chapter 9 →

Chapter 10: Habits tracker using gRPC

10.1 API definition · 10.1.1 Protobuf declaration · 10.1.2 Code generation · 10.2 Empty service · 10.2.1 Creating a small logger · 10.2.2 Server structure · 10.2.3 Creating and running the server · 10.3 First endpoint: Create · 10.3.1 Business layer · 10.3.2 API layer · 10.3.3 Data retention · 10.4 Unit testing with generated mocks · 10.4.1 Generate mocks · 10.4.2 Use the mocks · 10.5 Integration testing · 10.5.1 List habits · 10.5.2 Integration with go test · 10.6 Getting the best out of the context · 10.6.1 What is a context? · 10.6.2 Create a context · 10.6.3 Using a context · 10.7 Track your habits · 10.7.1 Tick a habit · 10.7.2 Store ticks per week · 10.7.3 Handle corner cases · 10.7.4 Get habit status · 10.7.5 Add a timestamp · 10.7.6 Habit tracker in action · 10.8 Summary

What you learn in chapter 10 →

Chapter 11: HTML templating with a gRPC client

11.1 Your basic HTTP server · 11.1.1 Hello plain text · 11.1.2 Templates: Display a variable · 11.1.3 Add a gRPC client · 11.2 Basic template operations · 11.2.1 Iterate through a slice · 11.2.2 Accessing fields · 11.2.3 Conditional formatting · 11.3 Send a tick to the server · 11.3.1 What page should we display? · 11.3.2 Send tick to the backend · 11.3.3 Adding colors · 11.4 Use a form to create a habit · 11.4.1 HTML form · 11.4.2 Read a form’s values · 11.5 More template niceties · 11.5.1 Passing more than one object to the template · 11.5.2 Calling functions · 11.5.3 Using define to declare functions · 11.6 Summary

What you learn in chapter 11 →

Chapter 12: Go for other architectures

12.1 Getting started with Wasm · 12.1.1 Some practice with Hello Wasm · 12.1.2 Write a file server · 12.2 Multiplication quiz project · 12.2.1 Displaying random numbers on the HTML page · 12.2.2 Registering functions in Go · 12.2.3 Reading an input from the page · 12.3 TinyGo · 12.3.1 Building a simple TinyGo application · 12.3.2 Differences with Go · 12.3.3 Debugging and deploying with TinyGo · 12.4 Summary

What you learn in chapter 12 →

Concepts explained in this book

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.