Whole-book reading guide from stratified index samples; jump to passages in the text
Tip the Site
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat Pay
Alipay
Open WeChat or Alipay and scan. No login required.
AI guide
【One-Line Pitch】
A hands-on, standard-library-only guide to building, testing, and deploying web applications in Go, ideal for developers with basic Go syntax who want to understand the underlying mechanics of HTTP, templates, and concurrency without relying on heavyweight frameworks.
【Book Arc】
- **Opening (~0%–10%)**: Introduces why Go is suited for scalable, modular, maintainable, and high-performance web apps, then lays down a strict definition of web applications (HTML + HTTP) and walks through HTTP fundamentals—requests, responses, methods, headers, status codes, and URIs—plus a brief history from CGI to modern template engines.
- **Early (~10%–25%)**: Builds a complete forum application (ChitChat) using only the standard library, covering request multiplexing, static file serving, handler functions, cookie-based access control, and HTML template generation, with PostgreSQL setup and database connection as the persistence layer.
- **Middle (~25%–50%)**: Dives deep into the core building blocks: the `net/http` server and handlers, processing requests (URLs, headers, bodies, forms, JSON), writing responses, and cookie management; then shifts to content display with Go's template engine—parsing, execution, actions (conditionals, iteration, inclusion), functions, and context-aware escaping to defend against XSS.
- **Middle (~50%–70%)**: Covers data storage options from in-memory and file-based (CSV, gob) to SQL with database/sql, including CRUD operations and relationships, and introduces ORM tools like Sqlx and Gorm; then moves to building web services with SOAP and REST, plus XML/JSON parsing and creation.
- **Late (~70%–90%)**: Focuses on testing (unit, HTTP, benchmarks, test doubles, dependency injection, third-party libraries like Gocheck and Ginkgo) and then concurrency—goroutines, channels, buffered channels, and select—applied to a real-world mosaic image generation web app to show performance gains.
- **Ending (~90%–100%)**: Discusses deployment strategies across standalone servers, Heroku, Google App Engine, and Docker, comparing approaches and covering containerization of a Go web app, ending with installation and setup guidance in the appendix.
【Key Takeaways】
- **Standard library is sufficient for production web apps** (Early): The book demonstrates that with `net/http`, `html/template`, and `database/sql`, you can build a full forum and web services without third-party frameworks, making the knowledge transferable to any framework or custom solution.
- **HTTP is the backbone of web development** (Early): Understanding request/response structure, methods (GET, POST, PUT, DELETE), status codes (1xx–5xx), and headers (Accept, Cookie, Content-Type) is essential for debugging and designing robust web applications.
- **Handlers and multiplexers are the core of request routing** (Middle): Go's `ServeMux` and handler functions allow flexible URL routing, chaining, and composition, and you can swap in alternative multiplexers for more complex routing needs.
- **Template engines separate logic from presentation** (Middle): Go's `html/template` supports actions (conditionals, iteration, inclusion), variables, pipelines, and functions, with context-aware escaping that automatically defends against XSS—a critical security feature.
- **Data persistence spans from simple to relational** (Middle): The book covers in-memory, file-based (CSV, gob), and SQL storage, showing how to perform CRUD and handle relationships, then introduces ORMs like Sqlx and Gorm for productivity gains.
- **Testing is integral to web development** (Late): Go's built-in testing package supports unit tests, benchmarks, and HTTP testing, while test doubles and dependency injection enable isolated and reliable tests; third-party tools like Ginkgo offer alternative styles.
- **Concurrency is a performance multiplier** (Late): Goroutines and channels enable efficient handling of thousands of concurrent requests on a single OS thread, and the mosaic image app demonstrates real-world performance improvements from concurrent processing.
- **Deployment is simplified by static binaries** (Ending): Go compiles to dependency-free static binaries, making deployment straightforward across standalone servers, PaaS platforms like Heroku, and containerized environments like Docker.
【Reading Tips】
- **Skim the HTTP theory chapters (1–2) if you're familiar with web basics**; they're thorough but foundational, and the real value is in the Go-specific implementation details that follow.
- **Deep-read the template and request handling chapters (4–5)**; they cover subtle but critical topics like form parsing, file uploads, JSON bodies, and context-aware escaping—these are where most bugs and security issues arise.
- **Follow along with the ChitChat forum example (Chapter 2)**; it's a complete application that ties together all the core concepts, so building it yourself will solidify your understanding of the request-to-response flow.
- **Pay special attention to the concurrency chapter (9)**; the mosaic image app is a practical, non-trivial example that shows how to structure concurrent code, so trace through the goroutine and channel usage carefully.
- **Use the deployment chapter (10) as a reference**; you don't need to read it linearly—jump to the platform you're targeting (Docker, Heroku, etc.) when you're ready to ship an app.
【Coverage Limits】
This guide synthesizes the book's core content on HTTP, handlers, templates, data storage, testing, concurrency, and deployment, but does not cover the full code listings or detailed API references from the original text.
n Kernighan 创作的 The Go Programming Language [2] 也是一本值得一读的好书。除了以上提到的两本书之外,网上也有非常多免费的Go教程可供浏览,比如,Go官方网站的《Go入门教程》(A Tour of Go)(http://tour.golang.org/)就是一个很棒的例...
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.
Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat PayAlipay
Open WeChat or Alipay and scan. No login required.
Add Tag
Enter tag name (max 50 characters)
Share E-Book
Go Web编程(异步图书) (郑兆雄 [郑兆雄])(Z-Library)
Scan QR code with your phone to access
Copy the link or scan the QR code to access this e-book on your phone
Share to WeChat Moments
Go Web编程(异步图书) (郑兆雄 [郑兆雄])(Z-Library)
Scan the QR code with WeChat to open this book
Tap the ··· menu in the top-right corner
Choose Share to Moments
You are already in WeChat. Tap ··· in the top-right corner and choose Share to Moments.
Share E-Book via Email
Please enter email address
Donation Statistics
¥.00
Total Donations
0
Donation Count
Go Web编程(异步图书) (郑兆雄 [郑兆雄])(Z-Library)
Find Your Favorite Books
Only registered users can comment after logging in. Comments need to be reviewed by administrators before being displayed
Loading comments...
Reply to Comment
Edit Comment