go-foundation

module
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2026 License: MIT

README

go-foundation

The standard library's missing standard library.

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

Directories

Path Synopsis
pkg
app
caching
Package caching provides a generic, thread-safe in-memory cache with TTL support.
Package caching provides a generic, thread-safe in-memory cache with TTL support.
configuration
Package configuration provides a flexible, multi-source configuration system inspired by .NET's IConfiguration pattern.
Package configuration provides a flexible, multi-source configuration system inspired by .NET's IConfiguration pattern.
di
plugin
Package plugin provides a focused plugin registry and supporting helpers.
Package plugin provides a focused plugin registry and supporting helpers.
srv
Package srv provides a minimal API server with routing, middleware, and model binding.
Package srv provides a minimal API server with routing, middleware, and model binding.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL