go-foundation

The standard library's missing standard library.

Go 1.24+ Zero dependencies MIT version

Read the Documentation


Packages

Package Description
hosting Application host with ConfigureServices / ConfigureWeb / DI / auto-start
srv Minimal API server with routing, middleware, model binding, auth, validation, rate limit
di Typed dependency injection (Singleton/Scoped/Transient)
configuration Multi-source config (env, file, flags)
options Functional options, Options[T], merge, validation
scheduler Cron-based background jobs, fire-and-forget, delayed
caching Cache[T] + DistributedCache interface + DistributedBridge[T]
serializer JSON serialization policy (SnakeCase, CamelCase, custom types)
telemetry Unified Tracer/Span/Meter/Counter/Histogram/Gauge (OTel-ready)
testutil TestHost (DI + HTTP test server), FakeLogger, TestResponse
validation Struct tag validation (required, email, min/max)
pipeline Generic middleware pipeline
health Health check registry
events Type-safe event bus (middleware, wildcard, async)
tracing Tracer/Span interface + noop
pooling Generic Pool[T] with finalizer
errutil Auto(), Wrap(), WError, Print(), Recover(), JoinErrors()
auth Token signing with key rotation (HMAC, RSA, ECDSA, EdDSA)
guard ABAC authorization via struct tags
relay Background job processor (pub/sub with context propagation)
httpx HTTP client middleware (retry, circuit breaker, logging)
logger Structured logging (console, CLEF, async)
plugin Plugin registry + lifecycle + sandbox exec
secrets Secret stores (memory, env, cipher, prefix, fallback)
worker Fixed-size goroutine pool
metrics Counter, Gauge, Histogram, Timer
saga Saga pattern with compensation LIFO
fsm Declarative finite state machine
tags Generic struct tag parser (cached)
hooks Lifecycle hook discovery + runner
resiliency Circuit breaker, retry, rate limiter, bulkhead
safemap Thread-safe map + sharded map with TTL
collections Set, OrderedSet, Queue, MultiMap, BiMap
lock Lock interface + in-memory implementation
reflectutil String-to-type binding + struct population
adapters Pluggable adapter registry
result Result[T] monad
ring Ring buffer (generic + byte)
cpio CPIO newc reader/writer
align Power-of-2 alignment
contracts Zero-cost interface contract markers
pointer Field offset registry

Panicking, but with style

defer errutil.Auto() // put this once at the top of main()

// to get panics like this:
  panic: runtime error: invalid memory address or nil pointer dereference

  1. main.main()
     /app/main.go:37
          35  func main() {
          36    defer errutil.Auto()
     >>   37    serve()
          38  }

  2. main.serve
     /app/main.go:9
           7  func serve() {
           8    h := &handler{}
     >>    9    h.handleRequest()
          10  }

  3. main.(*handler).handleRequest
     /app/main.go:15
          13  
          14  func (h *handler) handleRequest() {
     >>   15    h.authMiddleware(func() { h.dbQuery("42") })
          16  }

  4. main.(*handler).authMiddleware
     /app/main.go:19
          17  
          18  func (h *handler) authMiddleware(next func()) {
     >>   19    token := h.extractToken()
          20    if token == "" {

  5. main.(*handler).extractToken
     /app/main.go:28
          26  func (h *handler) extractToken() string {
          27    var t *string
     >>   28    return *t    ← crash here
          29  }

License

MIT

Created following the gopher style using AI (because I am not an illustration at this level).

Explore the SDK

adapters

Full API reference for the adapters package.

align

Full API reference for the align package.

app

Full API reference for the app package.

auth

Full API reference for the auth package.

bind

Full API reference for the bind package.

caching

Full API reference for the caching package.

collections

Full API reference for the collections package.

configuration

Full API reference for the configuration package.

env

Full API reference for the env package.

file

Full API reference for the file package.

contracts

Full API reference for the contracts package.

cpio

Full API reference for the cpio package.

di

Full API reference for the di package.

dispatcher

Full API reference for the dispatcher package.

errutil

Full API reference for the errutil package.

events

Full API reference for the events package.

machine

Full API reference for the machine package.

parser

Full API reference for the parser package.

visualizer

Full API reference for the visualizer package.

guard

Full API reference for the guard package.

guard_test

Full API reference for the guard_test package.

checker

Full API reference for the checker package.

health

Full API reference for the health package.

hooks

Full API reference for the hooks package.

hosting

Full API reference for the hosting package.

httpx

Full API reference for the httpx package.

httpx_test

Full API reference for the httpx_test package.

lock

Full API reference for the lock package.

logger

Full API reference for the logger package.

logger_test

Full API reference for the logger_test package.

metrics

Full API reference for the metrics package.

metrics_test

Full API reference for the metrics_test package.

openapi

Full API reference for the openapi package.

options

Full API reference for the options package.

pipeline

Full API reference for the pipeline package.

plugin

Full API reference for the plugin package.

plugin_test

Full API reference for the plugin_test package.

pointer

Full API reference for the pointer package.

pointer_test

Full API reference for the pointer_test package.

pooling

Full API reference for the pooling package.

reflectutil

Full API reference for the reflectutil package.

broker

Full API reference for the broker package.

manager

Full API reference for the manager package.

resiliency

Full API reference for the resiliency package.

result

Full API reference for the result package.

ring

Full API reference for the ring package.

safemap

Full API reference for the safemap package.

saga

Full API reference for the saga package.

scheduler

Full API reference for the scheduler package.

secrets

Full API reference for the secrets package.

secrets_test

Full API reference for the secrets_test package.

serializer

Full API reference for the serializer package.

srv

Full API reference for the srv package.

tags

Full API reference for the tags package.

telemetry

Full API reference for the telemetry package.

testutil

Full API reference for the testutil package.

tracing

Full API reference for the tracing package.

validation

Full API reference for the validation package.

worker

Full API reference for the worker package.

worker_test

Full API reference for the worker_test package.