Go

Notes on the Go programming language — interfaces, concurrency, testing, and patterns that have held up in production.

Omitting dev dependencies in Go binaries

Track dev dependencies like golangci-lint in go.mod with a tools.go file and build tags to exclude them from production binaries.

Rate limiting via Nginx

Implement rate limiting at the infrastructure layer with Nginx reverse proxy. Protect Go services from DDoS with leaky bucket algorithm.

Reminiscing CGI scripts

Build a CGI script from scratch using Go's stdlib and Bash. Understand why Common Gateway Interface fell out of favor for modern web apps.

Configuring options in Go

Compare three Go option patterns: exposed structs, option constructors, and functional options. Learn when to use each for clean APIs.

Dummy load balancer in a single Go script

Build a working round-robin load balancer in Go with goroutines and the standard library. No dependencies needed for this educational prototype.

Limit goroutines with buffered channels

Control goroutine concurrency with buffered channels as semaphores. Prevent resource exhaustion with backpressure patterns in Go workers.

Writing a TOTP client in Go

Build a TOTP-based 2FA client in Go using the standard library. Generate time-based one-time passwords like Google Authenticator.

Interface guards in Go

Use compile-time interface guards to verify type conformity in Go without runtime overhead. Learn the var _ Interface = (*Type)(nil) pattern.

Go structured logging with slog

Master Go 1.21's log/slog package for structured logging with levels, JSON output, and attribute grouping. No third-party libraries needed.