Leanpub Header

Skip to main content

The Go Programming Handbook

A Complete Guide to Building Production-Grade Applications in Golang

The Go Programming Handbook
This book is 100% completeLast updated on 2026-11-14

Build fast, reliable, and scalable software with Go. From core language fundamentals to advanced concurrency, testing, and production deployment, The Golang Handbook guides you through every stage of modern Go development with practical examples and real-world techniques, helping you write clean, efficient code with confidence.

Minimum price

$25.00

$35.00

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
WEB
APP
235
Pages
About

About

About the Book

This book takes you from writing your first line of Go code to deploying production-grade, concurrent, and scalable applications. Through detailed explanations, complete runnable examples, and real-world patterns, you will learn every facet of the Go programming language: its design philosophy, syntax, concurrency model, standard library, testing practices, and deployment strategies. Whether you are a beginner picking up Go for the first time or an experienced developer seeking mastery, this book provides a clear, step-by-step path to becoming a confident Go engineer.

Bundle

Bundles that include this book

Author

About the Author

Steve Publications

Steve is a technology professional with more than 20 years of experience spanning software development, server infrastructure, cybersecurity, vulnerability research and reverse engineering. His work focuses on understanding complex systems, uncovering security weaknesses and developing practical solutions that make technology more secure, reliable and effective.

Through Steve Publications, he collaborates with experienced researchers, engineers and industry experts to create practical, technically rigorous books on various topics not limited to self-improvement, software development, cybersecurity, cloud computing, DevOps, artificial intelligence and enterprise technologies. His mission is to make complex technical subjects accessible through clear explanations, real-world examples and hands-on exercises that help IT professionals, students and technology enthusiasts build valuable, practical skills.

Steve Publications embraces AI as a supporting tool for translation, proofreading and editorial refinement, not as a substitute for original research, technical expertise, or hands-on experience. Some contributors choose to publish under pseudonyms to protect their privacy or maintain professional boundaries.

Behind every book is a commitment to technical accuracy, practical relevance and continuous improvement. Our publications are written, reviewed and maintained by experienced professionals, with support from a private community of more than 420 engineers and researchers. Rather than prioritizing volume or mass-produced AI-generated content, we focus on delivering reliable, useful resources that readers can apply in real-world environments.

We also welcome experienced professionals who want to share their knowledge by writing or reviewing books, particularly in specialized and emerging technology fields. If you have expertise to contribute, we invite you to get in touch and explore opportunities to collaborate.

Our commitment is simple: To deliver books that respect our readers' time, support their professional growth and provide lasting practical value. If a book does not meet your expectations, Leanpub offers a 60-day money-back guarantee.

Contents

Table of Contents

The Golang Handbook

A Complete Guide to Building Production-Grade Applications in Golang

Introduction: Why Go and Why Now?

  1. What Makes Go Different
  2. Who This Book Is For
  3. How to Use This Book
  4. What You Will Need
  5. A Note on Go Versions

Chapter 1: Welcome to Go - History, Philosophy and First Steps

  1. The Birth of Go at Google
  2. Design Philosophy: Simplicity, Readability and Pragmatism
  3. Installing Go and Setting Up Your Environment
  4. Your First Go Program: Anatomy of main.go
  5. The Go Toolchain: Build, Run and Format
  6. Your First Project: A Temperature Converter
  7. Summary and Key Takeaways

Chapter 2: Language Fundamentals - Variables, Types and Control Flow

  1. Variables, Constants and Zero Values
  2. Primitive Types: Integers, Floats, Booleans and Strings
  3. Type Inference with var and Short Declaration :=
  4. Control Structures: if/else, switch and for Loops
  5. Operators and Precedence
  6. Summary and Key Takeaways

Chapter 3: Functions, Packages and Modules

  1. Defining and Calling Functions
  2. Multiple Return Values and Named Returns
  3. Variadic Functions and ... Syntax
  4. Package Declaration, Imports and Visibility Rules
  5. Go Modules: go.mod, Dependency Management and Versioning
  6. The init() Function
  7. Summary and Key Takeaways

Chapter 4: Pointers, Structs and Methods

  1. Understanding Pointers: & and * Operators
  2. When to Use Pointers vs. Values
  3. Defining and Using Structs
  4. Struct Tags and Their Purpose
  5. Methods: Value Receivers vs. Pointer Receivers
  6. Summary and Key Takeaways

Chapter 5: Interfaces and Duck Typing in Go

  1. What Is an Interface and Why Go Does It Differently
  2. Implicit Implementation: No implements Keyword
  3. The Empty Interface interface{} and Type Assertions
  4. Designing Small Interfaces: io.Reader, io.Writer and the Standard Library Pattern
  5. Interface Internals: How Interfaces Work Under the Hood
  6. Summary and Key Takeaways

Chapter 6: Error Handling, Defer, Panic and Recover

  1. Errors as Values: The error Interface
  2. Creating Custom Error Types with errors.New and fmt.Errorf
  3. Wrapped Errors and errors.Is / errors.As (Go 1.13+)
  4. defer: Deferred Function Execution and Stack Unwinding
  5. panic and recover: When to Use Them (and When Not To)
  6. Error Handling: The Verbosity Debate
  7. Summary and Key Takeaways

Chapter 7: Slices, Maps and Collections

  1. Arrays: Fixed-Length Sequences
  2. Slices: Dynamic Views onto Arrays
  3. Slice Internals: Length, Capacity and make()
  4. The append Function and Slice Aliasing Pitfalls
  5. Maps: Hash Tables in Go
  6. Summary and Key Takeaways

Chapter 8: Generics in Go - Type Parameters and Constraints

  1. Why Generics Took So Long: The Design Debate
  2. Type Parameters and Generic Functions
  3. Type Constraints: Interfaces as Constraints and comparable
  4. Generic Structs and Methods
  5. Practical Patterns: Collections, Algorithms and API Libraries
  6. Summary and Key Takeaways

Chapter 9: File I/O and Disk Operations

  1. Reading and Writing Files: os.ReadFile and os.WriteFile
  2. Opening Files: os.Open, os.Create and os.OpenFile
  3. Buffered I/O with bufio
  4. Reading Files Line by Line with bufio.Scanner
  5. Writing Files with bufio.Writer
  6. Atomic File Writes: Preventing Partial Reads
  7. Path Manipulation with path/filepath
  8. Walking Directories with filepath.Walk and filepath.WalkDir
  9. File Metadata and Permissions with os.Stat
  10. Streaming Large Files: Chunked Reading
  11. Logging to Disk: A Practical Example
  12. Temporary Files and Directories
  13. Summary and Key Takeaways

Chapter 10: Strings, Text Processing and Encoding

  1. Strings in Go: Immutable Byte Sequences
  2. UTF-8 and Rune Handling
  3. String Operations: strings, strconv and fmt Packages
  4. Regular Expressions with regexp
  5. JSON and XML Encoding/Decoding
  6. CSV and Other Data Formats
  7. Summary and Key Takeaways

Chapter 11: Concurrency - Goroutines, Channels and Synchronization

  1. Goroutines: Lightweight Concurrent Execution
  2. Channels: Communication Between Goroutines
  3. Buffered vs. Unbuffered Channels
  4. select: Multiplexing Channel Operations
  5. The sync Package: Mutexes, WaitGroups, Once and More
  6. Concurrency Patterns: Worker Pools, Fan-In/Fan-Out, Pipelines
  7. Advanced Concurrency Debugging: The Race Detector
  8. Execution Tracing for Concurrency Analysis
  9. Common Concurrency Failure Modes
  10. Channels vs. Mutexes: A Balanced Perspective
  11. Summary and Key Takeaways

Chapter 12: Context, Cancellation and Request Scopes

  1. What Is Context and Why It Matters
  2. Creating Contexts: background, todo and Derived Contexts
  3. Timeouts and Deadlines with context.WithTimeout and WithDeadline
  4. Cancellation Propagation in Concurrent Programs
  5. Storing Request-Scoped Values (and When Not To)
  6. Production Case Study: Context Cancellation Across Microservices
  7. Context Best Practices and Common Mistakes
  8. Summary and Key Takeaways

Chapter 13: Testing, Benchmarking and Profiling

  1. The testing Package: Writing Unit Tests
  2. Table-Driven Tests: Go’s Idiomatic Testing Pattern
  3. Test Helpers, Subtests and Parallel Tests
  4. Benchmarking with go test -bench
  5. Fuzzing with go test -fuzz (Go 1.18+)
  6. Profiling: CPU, Memory and Block Profiles with pprof
  7. Profiling-Driven Optimization: A Systematic Workflow
  8. Integration Testing and Test Fixtures
  9. Summary and Key Takeaways

Chapter 14: Web Development and HTTP APIs

  1. Building HTTP Servers with net/http
  2. HTTP Clients and Making Requests
  3. Building RESTful APIs: Routing, Middleware and Handlers
  4. JSON Request/Response Handling
  5. Summary and Key Takeaways

Chapter 15: Data Persistence and Distributed Communication

  1. Database Access: database/sql, Drivers and Connection Pools
  2. ORM vs. Raw SQL: A Balanced Perspective
  3. gRPC: Protobuf Definitions and Server/Client Implementation
  4. WebSockets with gorilla/websocket or nhooyr.io/websocket
  5. Summary and Key Takeaways

Chapter 16: Production Go – Architecture, Deployment and Beyond

  1. Project Organization: Standard Go Project Layout
  2. Clean Architecture and Dependency Injection in Go
  3. Logging: log/slog and Structured Logging
  4. Configuration Management: Environment Variables, Viper and Flags
  5. Security Best Practices: Authentication, Input Validation and Secrets
  6. CLI Applications with cobra and viper
  7. Containerization with Docker and Multi-Stage Builds
  8. CI/CD Pipelines for Go Applications
  9. Microservice Patterns: Service Discovery, Circuit Breakers and Message Queues
  10. Performance Optimization: Escape Analysis, Allocation Reduction and GC Tuning
  11. Memory Management and Garbage Collection Internals
  12. Reflection: reflect Package and When to Use It
  13. Summary and Key Takeaways

Conclusion: Your Journey as a Go Engineer

  1. What You Have Learned
  2. The Go Mindset
  3. What Comes Next
  4. Final Thoughts

References

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub