go

go
package middleware

import (
  "log"
  "net/http"
  "runtime/debug"

Panic recovery middleware that fails closed and logs context

go http middleware
by Leah Thompson 1 tab
go
package paging

import (
  "encoding/base64"
  "encoding/json"
  "time"

Cursor pagination: opaque tokens with stable ordering

go api pagination
by Leah Thompson 1 tab
go
package web

import (
  "bytes"
  "html/template"
  "net/http"

Template rendering with html/template and strict escaping

go templates http
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 pool

import "context"

type Job func(ctx context.Context) error

Bounded worker pool with backpressure

go concurrency worker-pool
by Leah Thompson 1 tab
go
package metrics

import (
  "net/http"
  "strconv"
  "time"

Prometheus metrics middleware capturing status + duration

go prometheus metrics
by Leah Thompson 1 tab
go
package flags

import (
  "context"
  "encoding/json"
  "sync/atomic"

Feature flag snapshot with periodic refresh and atomic reads

go config reliability
by Leah Thompson 1 tab
go
package export

import (
	"encoding/csv"
	"log"
	"net/http"

Streaming Large CSV Exports in Go Without Buffering the Whole File

go http csv
by codesnips 3 tabs
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 health

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

Readiness and liveness probes with dependency checks

go http kubernetes
by Leah Thompson 1 tab
go
package store

import (
  "context"

  sq "github.com/Masterminds/squirrel"

Safe dynamic SQL with squirrel (optional filters, stable ordering)

go sql postgres
by Leah Thompson 1 tab
go
package observability

import (
  "context"

  "go.opentelemetry.io/otel"

OpenTelemetry tracer provider with ratio-based sampling

go observability opentelemetry
by Leah Thompson 1 tab