go

go
package middleware

import "net/http"

type StatusRecorder struct {
  http.ResponseWriter

Capture status code and bytes written via ResponseWriter wrapper

go http observability
by Leah Thompson 1 tab
go
package deps

import (
  "context"
  "net/http"
  "time"

Circuit breaker around flaky dependencies

go reliability circuit-breaker
by Leah Thompson 1 tab
go
package middleware

import (
  "compress/gzip"
  "net/http"
  "strings"

Gzip compression middleware with correct Vary header

go http middleware
by Leah Thompson 1 tab
go
package middleware

import (
  "net"
  "net/http"
  "net/netip"

CIDR allowlist middleware using netip (trust boundary explicit)

go http security
by Leah Thompson 1 tab
go
package cache

import (
  "context"
  "sync/atomic"
  "time"

Context-aware cache refresh with atomic.Pointer (Go 1.19+)

go concurrency cache
by Leah Thompson 1 tab
go
package hotpath

import "testing"

func BenchmarkParse(b *testing.B) {
  b.ReportAllocs()

Benchmarking hot paths (allocs and throughput)

go performance benchmarking
by Leah Thompson 1 tab
go
package api

import (
  "net/http"
  "strings"
)

Enforce JSON Content-Type and method early in handlers

go http api
by Leah Thompson 1 tab
go
package cache

import (
  "context"
  "sync"
  "time"

Singleflight cache fill to prevent thundering herd

go cache concurrency
by Leah Thompson 1 tab
go
package mail

import (
  "context"
  "bytes"
  "encoding/json"

Email delivery via HTTP provider with context, timeout, and idempotency

go email background-jobs
by Leah Thompson 1 tab
sql
ALTER TABLE documents ADD COLUMN version BIGINT NOT NULL DEFAULT 0;

Optimistic locking with a version column

go postgres sql
by Leah Thompson 2 tabs
go
package main

import (
  "os"
  "runtime/debug"
  "strconv"

Set a soft memory limit with debug.SetMemoryLimit

go performance memory
by Leah Thompson 1 tab
go
package observability

import (
  "expvar"
  "net/http"
)

expvar counters for quick-and-dirty production introspection

go observability metrics
by Leah Thompson 1 tab