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 middleware

import (
  "net/http"

  "golang.org/x/time/rate"

Inbound rate limiting middleware with token bucket

go http rate-limit
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 observability

import (
  "time"

  "go.uber.org/zap"

Sampling logs to reduce noise during high-QPS incidents

go logging observability
by Leah Thompson 1 tab
go
package deps

import "sync"

type Lazy[T any] struct {
  once sync.Once

Lazy init of expensive clients with sync.Once

go concurrency sync
by Leah Thompson 1 tab
go
package debughttp

import (
  "context"
  "crypto/tls"
  "net/http"

HTTPtrace to debug DNS/connect/TLS timing in production-like runs

go http client
by Leah Thompson 1 tab
go
package migrate

import (
  "context"

  "github.com/jackc/pgx/v5/pgxpool"

Run database migrations on startup (with a guard)

go postgres migrations
by Leah Thompson 1 tab
go
package store

import (
  "context"
  "database/sql"
)

db/sql prepared statements with context and explicit Close

go sql postgres
by Leah Thompson 1 tab
go
package ingest

import (
  "bufio"
  "bytes"
  "io"

Avoid bufio.Scanner token limits by switching to Reader

go io logs
by Leah Thompson 1 tab
go
package importers

import (
  "context"
  "encoding/csv"
  "io"

Streaming CSV import with batched inserts

go csv postgres
by Leah Thompson 1 tab
go
package types

import (
  "bytes"
  "encoding/json"
  "time"

Strict JSON time parsing with custom UnmarshalJSON

go json time
by Leah Thompson 1 tab
go
package main

import (
  "time"

  "google.golang.org/grpc"

Graceful gRPC shutdown with fallback to Stop

go grpc shutdown
by Leah Thompson 1 tab