From Language Fundamentals to Production-Grade Distributed Systems
Chapter 1: Why Go for Systems Programming
- The Problem Space: What Is Systems Programming Today
- Go’s Design Philosophy: Simplicity, Explicitness and Pragmatism
- A Brief History: From Google’s Internals to Industry Standard
- Installing Go 1.27 and Verifying Your Toolchain
- Modules and the go Command: Dependency Management from Day One
- Building Your First Systems Program: A Minimal HTTP Server with Metrics
- References for Chapter 1
Chapter 2: Language Fundamentals for Systems Engineers
- Types, Variables and Constants: Static Typing as a Safety Mechanism
- Control Flow: Statements, Loops and Early Returns
- Functions and Methods: Single Return Values vs Multiple Returns
- Structs and Composition: Building Complex Data Without Inheritance
- Slices: Dynamic Arrays for Efficient Buffer Management
- Maps: Hash Tables for Fast Lookups in Concurrent Systems
Chapter 3: Interfaces, Generics and Go 1.27’s Generic Methods
- Duck Typing with Interfaces: Implicit Satisfaction and Design Flexibility
- The Empty Interface and Type Assertions: Working with Unknown Types
- Generics in Go: Type Parameters for Reusable Collections and Algorithms
- Generic Methods Arrive in Go 1.27: Syntax, Use Cases and Limitations
- Struct Literal Field Selectors and Generalized Type Inference in Go 1.27
- When to Use What: Interfaces vs Generics vs Concrete Types
- References for Chapter 3
Chapter 4: Error Handling and Resource Management
- Errors as Values: The Philosophy Behind Go’s Approach
- Creating, Wrapping and Inspecting Errors with errors.Is and errors.As
- Sentinel Errors vs Error Types: Choosing the Right Abstraction
- Context Package: Cancellation, Timeouts and Request Scoping
- Resource Cleanup Patterns: defer, finalizers and RAII alternatives
- Building Robust Error Handling into Production Services
- References for Chapter 4
Chapter 5: Concurrency Foundations: Goroutines and Channels
- Goroutines: Lightweight Threads Managed by the Runtime Scheduler
- Channels: Typed Communication Between Concurrent Tasks
- Buffered vs Unbuffered Channels: When Each Matters
- select Statements: Multiplexing Across Multiple Operations
- The sync Package: Mutexes, RWMutex, WaitGroups and Once
- Data Races and the race Detector: Finding Bugs Before Production
- References for Chapter 5
Chapter 6: Advanced Concurrency Patterns for Production
- Worker Pools and Bounded Concurrency: Controlling Resource Usage
- Pipelines and Fan-Out/Fan-In: Parallel Processing of Data Streams
- Pub/Sub with Channels: Event-Driven Architecture Without Frameworks
- Context-Aware Workers: Propagating Cancellation Through the Stack
- Graceful Shutdown: Draining Requests, Closing Connections, Flushing Buffers
- Preventing Goroutine Leaks: Patterns and Go 1.27’s goroutineleak Profile
- References for Chapter 6
Chapter 7: Memory Management, Pointers and Performance
- Stack vs Heap: How the Compiler Decides Where Variables Live
- Escape Analysis: Understanding Allocation Decisions
- Pointers vs Values: When Each Is Appropriate in Systems Code
- The Garbage Collector: Tracing, Write Barriers and Pause Times
- Memory Profiling with pprof: Finding Leaks and Hotspots
- The unsafe Package: Breaking the Rules Responsibly
- References for Chapter 7
Chapter 8: Filesystems, Processes and Operating System Integration
- The os and os/file packages: Creating, Reading, Writing Files
- Path Manipulation and Directory Traversal with filepath
- File Permissions, Ownership and Atomic Writes
- Process Management: Starting, Monitoring and Killing Child Processes
- Signal Handling: SIGINT, SIGTERM, SIGHUP and Graceful Responses
- Environment Variables, User Lookup and System Information
- References for Chapter 8
Chapter 9: Networking, Protocols and HTTP Services
- The net Package: TCP and UDP Sockets for Custom Protocols
- Building a Simple Protocol Handler: Request/Response Over TCP
- HTTP Clients and Servers with net/http: Routing, Middleware, Handlers
- TLS Configuration and Post-Quantum Signatures with crypto/mldsa in Go 1.27
- Connection Pooling and Keep-Alive: Optimizing Network Performance
- Building a Production HTTP Service End-to-End
- References for Chapter 9
Chapter 10: Serialization, Databases and Persistence
- JSON v2 in Go 1.27: API Changes, Performance Gains, Migration Guide
- Protocol Buffers and Binary Serialization for Internal Communication
- UUID Generation with the New Standard Library uuid Package in Go 1.27
- Database Access with database/sql: Connection Pools, Transactions, Migrations
- Caching Patterns: In-Memory Caches with sync.Map and Time-based Expiration
- Message Queues and Background Workers: Processing at Scale
- References for Chapter 10
Chapter 11: Observability: Logging, Metrics and Tracing
- Structured Logging with slog: The Go 1.21+ Standard Approach
- Designing Log Levels and Fields for Production Debugging
- Metrics Collection: Counters, Gauges, Histograms and Percentiles
- OpenTelemetry Integration: Distributed Tracing Across Services
- Profiling in Production: pprof Endpoints, Safety and Automation
- Goroutine Leak Detection with Go 1.27’s goroutineleak Profile
- References for Chapter 11
Chapter 12: Testing, Profiling and Performance Optimization
- Unit Testing with the testing Package: Tables, Subtests and Fuzzing
- Integration Tests: Mocks, Test Servers and httptest.NewTestServer in Go 1.27
- Benchmarking Methodology: Writing Meaningful Benchmarks and Comparisons
- Profiling CPU, Memory and Block Contention with pprof
- Flame Graphs and Hotspot Analysis: Finding the Real Bottlenecks
- Optimization Techniques: Reducing Allocations, Cache Locality, SIMD
- References for Chapter 12
Chapter 13: Security, Containers and Deployment
- Security Fundamentals in Go: Input Validation, Authentication and Secrets Management
- HTTP Security Headers, CORS and Rate Limiting
- Containerization with Docker: Multi-Stage Builds and Minimal Images
- Cross-Compilation: Building for Multiple Platforms from a Single Environment
- Deployment Patterns: Health Checks, Readiness Probes and Kubernetes Integration
- References for Chapter 13
Chapter 14: Distributed Systems in Go: gRPC, Resilience and Infrastructure Software
- gRPC Services: Definition, Code Generation and Bidirectional Streaming
- Resilience Patterns: Retries, Timeouts, Circuit Breakers and Bulkheads
- Distributed Tracing Across gRPC and HTTP Services
- Consensus and Distributed State: Raft Implementation with Hashicorp’s raft Library
- Building Production Infrastructure Software in Go
- References for Chapter 14