Skip to content

googollee/module

Repository files navigation

Go Reference License Status Security Status Tests codecov

Module

A type-safe, performance-focused dependency injection framework for Go, built on top of context.Context.

Key Features

  • Type-Safe: No interface{} type assertions in your business logic.
  • High Performance: No reflection penalty at runtime; retrieval is a simple map lookup.
  • Context-Based: Seamlessly integrates with standard Go middleware and request flows.
  • Robust: Built-in circular dependency detection and deterministic injection order.
  • Reliable: 100% test coverage.

Quick Start

// 1. Define a module token
var ModuleDB = module.New[DB]()

// 2. Register a provider
repo := module.NewRepo()
repo.Add(ModuleDB.ProvideValue(&db{target: "local.db"}))

// 3. Inject and use
ctx, _ := repo.InjectTo(context.Background())
database := ModuleDB.Value(ctx) // Returns DB type directly

For more detailed usage, including dependency chains and scoped overrides, see the Examples or Go Reference.

License

FOSSA Status

About

A type-based dependency injection framework for Go.

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages