Practical Go

Book description

Step-by-step instruction on writing your first production-ready servers with Golang

Google's Go language, otherwise known as Golang, is a fast, simple, and reliable language that is rapidly becoming a highly popular choice for developers of all kinds. With particular utility in cloud-native environments, Golang is being adopted in major projects like Docker and Ethereum thanks to its user-friendly features, like concurrency and easy deployment.

In Practical Golang: Building Scalable Network and Non-Network Applications, expert coder and devops engineer Amit Saha delivers a step-by-step guide to writing production-ready HTTP 1.1, HTTP2, RPC, and TCP/UDP servers. Walking you through the entire process of learning this already straightforward language, from your first application to your first deployed server, the authors rely solely on the most popular open-source projects to ensure you can apply the book's advice in any cloud environment.

In this book, you'll get:

  • Fulsome descriptions of best practices on load balancing, scaling, and failure handling
  • Stepwise guidance on writing an HTTP service from scratch using only Golang's standard library
  • Easy tutorials on implementing RPC and HTTP interfaces for RPC services
  • Straightforward instructions on using SQL databases

Perfect for software developers, devops engineers, and other programming professionals, Practical Golang is also an indispensable resource for anyone who wants to go beyond the basics of Golang and deploy robust and practical servers.

Table of contents

  1. Cover
  2. Title Page
  3. Introduction
    1. What Does This Book Cover?
    2. Reader Support for This Book
  4. Getting Started
    1. Installing Go
    2. Choosing an Editor
    3. Installing Protocol Buffer Toolchain
    4. Installing Docker Desktop
    5. Guide to the Book
    6. Go Refresher
    7. Summary
  5. CHAPTER 1: Writing Command-Line Applications
    1. Your First Application
    2. Writing Unit Tests
    3. Using the Flag Package
    4. Improving the User Interface
    5. Updating the Unit Tests
    6. Summary
  6. CHAPTER 2: Advanced Command-Line Applications
    1. Implementing Sub-commands
    2. Making Your Applications Robust
    3. Summary
  7. CHAPTER 3: Writing HTTP Clients
    1. Downloading Data
    2. Deserializing Received Data
    3. Sending Data
    4. Working with Binary Data
    5. Summary
  8. CHAPTER 4: Advanced HTTP Clients
    1. Using a Custom HTTP Client
    2. Customizing Your Requests
    3. Implementing Client Middleware
    4. Connection Pooling
    5. Summary
  9. CHAPTER 5: Building HTTP Servers
    1. Your First HTTP Server
    2. Setting Up Request Handlers
    3. Testing Your Server
    4. The Request Struct
    5. Attaching Metadata to a Request
    6. Processing Streaming Requests
    7. Streaming Data as Responses
    8. Summary
  10. CHAPTER 6: Advanced HTTP Server Applications
    1. The Handler Type
    2. Sharing Data across Handler Functions
    3. Writing Server Middleware
    4. Writing Tests for Complex Server Applications
    5. Summary
  11. CHAPTER 7: Production-Ready HTTP Servers
    1. Aborting Request Handling
    2. Server-Wide Time-Outs
    3. Implementing Graceful Shutdown
    4. Securing Communication with TLS
    5. Summary
  12. CHAPTER 8: Building RPC Applications with gRPC
    1. gRPC and Protocol Buffers
    2. Writing Your First Service
    3. A Detour into Protobuf Messages
    4. Multiple Services
    5. Error Handling
    6. Summary
  13. CHAPTER 9: Advanced gRPC Applications
    1. Streaming Communication
    2. Receiving and Sending Arbitrary Bytes
    3. Implementing Middleware Using Interceptors
    4. Summary
  14. CHAPTER 10: Production-Ready gRPC Applications
    1. Securing Communication with TLS
    2. Robustness in Servers
    3. Robustness in Clients
    4. Connection Management
    5. Summary
  15. CHAPTER 11: Working with Data Stores
    1. Working with Object Stores
    2. Working with Relational Databases
    3. Summary
  16. APPENDIX A: Making Your Applications Observable
    1. Logs, Metrics, and Traces
    2. Emitting Telemetry Data
    3. Summary
  17. APPENDIX B: Deploying Applications
    1. Managing Configuration
    2. Distributing Your Application
    3. Deploying Server Applications
    4. Summary
  18. Index
  19. Copyright
  20. Dedication
  21. About the Author
  22. About the Technical Editor
  23. Acknowledgments
  24. End User License Agreement

Product information

  • Title: Practical Go
  • Author(s): Amit Saha
  • Release date: December 2021
  • Publisher(s): Wiley
  • ISBN: 9781119773818