Learn Go with Pocket-Sized Projects (Final) (Aliénor Latour, Donia Chaiehloudj etc.)(Z-Library)
Code
No description
AI Reading Assistant
Whole-book reading guide from stratified index samples; jump to passages in the text
AI guide
【One-Line Pitch】
Learn Go by building 12 small, practical projects—from a CLI greeting tool to a gRPC habit tracker and WebAssembly experiments—perfect for busy developers who want hands-on experience with real-world Go patterns, testing, and architecture.
【Book Arc】
- **Opening (~0%–10%)**: Introduces the book's philosophy of learning through small, timed projects, then starts with a simple CLI tool that greets users in multiple languages, teaching basic syntax, maps, and function structure.
- **Early (~10%–23%)**: Builds a bookworm CLI tool that parses JSON book collections, teaching file I/O, JSON decoding, slices vs. arrays, and sorting—plus a logging library project that introduces interfaces, zero values, and closed-box testing.
- **Early-Middle (~23%–39%)**: Develops "Gordle," a Wordle clone, covering rune handling, string manipulation, game state management, and table-driven tests with feedback logic.
- **Middle (~39%–48%)**: Creates a money/currency package that handles decimal precision (avoiding float issues) and fetches exchange rates via HTTP, teaching custom types, error handling, and testing HTTP calls with `httptest`.
- **Late (~48%–75%)**: Covers more advanced projects including a maze exploration tool (overcoming loop constraints, animation) and a gRPC-based habit tracker with Protobuf definitions, code generation, server/client architecture, and unit/integration testing with mocks.
- **Ending (~75%–100%)**: Explores WebAssembly and TinyGo for edge/embedded environments, with appendices on benchmarking, fuzz testing, and database connections.
【Key Takeaways】
- **Learning by doing is the core method** (Early): Each chapter is a self-contained project designed to be completed in a short session, reinforcing concepts through immediate application rather than abstract theory.
- **Slices over arrays in practice** (Early): Arrays have fixed lengths baked into their type, making them inflexible; slices provide dynamic views and are the idiomatic choice for most Go code.
- **JSON handling requires exported fields** (Early): The `encoding/json` package can only decode into exported struct fields, and using `json.Decoder` with `io.Reader` is preferred over `json.Unmarshal` for streaming data.
- **Table-driven tests are a Go best practice** (Early): Structuring tests as maps of cases with expected outcomes makes them readable, maintainable, and easy to extend—as shown in the Gordle feedback tests.
- **Custom types hide implementation details** (Middle): The money package exposes a `Decimal` type while keeping internal representation private, allowing refactoring without breaking the API—a key design principle.
- **Error handling is explicit and deliberate** (Middle): Go uses sentinel errors and error propagation as the primary mechanism for handling failures, with functions returning errors as their last return value.
- **Testing HTTP calls requires mocking** (Middle): The `httptest` package provides a lightweight server for testing HTTP-dependent code without making real network calls, keeping unit tests fast and reliable.
- **Contexts manage request lifecycle** (Late): The gRPC habit tracker demonstrates how `context.Context` carries deadlines, cancellations, and values across API boundaries, essential for production services.
【Reading Tips】
- **Skim the theory sections** (Early): The book weaves in language fundamentals alongside projects; if you're already comfortable with Go basics, focus on the project code and skip ahead to the "why" discussions.
- **Deep-read the testing chapters** (Early–Middle): Testing is a recurring theme—from closed-box testing to table-driven tests and mock generation—so pay close attention to how tests are structured and why.
- **Watch for the "Side Quests"** (Early): These small exercises reinforce concepts and often introduce useful tips (like emoji insertion shortcuts); they're worth doing even if you skip other parts.
- **Type out the code yourself** (All): The authors emphasize writing code manually rather than copying; this builds muscle memory and helps you catch details the text explains.
- **Use the appendices as reference** (Ending): Benchmarking, fuzz testing, and database connections are covered in short tutorials—return to these when you need them in your own projects.
【Coverage Limits】
This guide covers the book's first half in detail (through the money/currency project and HTTP testing). Later chapters on gRPC, WebAssembly, and TinyGo are summarized from the table of contents but not deeply excerpted.
Excerpt 1
xed-width font like this to separate it from ordinary text. In many cases, the original source code has been reformatted; we’ve added line breaks and reworke...
View in text
Excerpt 2
at least two error cases: (1) if the indicated file doesn’t exist, and (2) if the formatting of the file is invalid. Let’s invent a file path that doesn’t ex...
View in text
Excerpt 3
the maximum number of attempts. #2 Asks for a valid word #3 We’ve exhausted the number of allowed attempts. USING EMOJIS To insert emojis, use Ctrl-Cmd-Space...
View in text
Excerpt 4
nformation, that function will be skipped.” This means that you’ll be able to see which test broke, rather than this helper function’s line number. Listing 6...
View in text
Excerpt 5
return Cache[K, V]{ ttl: ttl, data: make(map[K]entryWithTimeout[V]), maxSize: maxSize, chronologicalKeys: make([]K, 0, maxSize), } } #1 Passes the maximum si...
View in text
Excerpt 6
temptsLeft == 0: game.Status = session.StatusLost default: game.Status = session.StatusPlaying } err = db.Update(game) #7 return game, nil } #1 Does the game...
View in text
Excerpt 7
orce it. #2 Adds some niceties to the default log package Now that we have our basic logger, we can start implementing the server package. We’ll need this lo...
View in text
Excerpt 8
The main well-known mock tools are mockgen (comes with Go), mockify, and minimock, which we used in this chapter. The standard context library provides the C...
View in text
Tags
AI categories
Programming LanguageGoBackend
Text Preview (First 20 pages)
Registered users can read the full content for free
Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.
Generating text preview…
Loading comments...
Reply to Comment
Edit Comment