Kessoku
Kessoku is a compile-time dependency injection library for Go that speeds up application startup through parallel dependency injection. Unlike traditional DI frameworks that initialize services sequentially, Kessoku automatically executes independent providers in parallel, dramatically reducing startup time for applications with multiple slow services. Built as a powerful alternative to google/wire, it generates optimized code at compile time with zero runtime overhead.
Sequential: DB → Cache → Auth = Total waiting time Parallel: DB + Cache + Auth = Fastest service wins
// Before: Sequential (google/wire)
wire.Build(NewDB, NewCache, NewAuth, NewApp) // Each waits for previous
// After: Parallel (Kessoku)
kessoku.Inject*App), // }
kessoku.Async(kessoku.Provide(NewCache)), // } All run together
kessoku.Async(kessoku.Provide(NewAuth)), // }
kessoku.Provide(NewApp), // waits for all
) // Fastest possible startup
Result: Every restart gets faster. Multiple slow services? Maximum impact.
Why This Matters
Your typical day: Restart your app 10 times during development. Each restart wastes time waiting for services to start one by one.
gantt
title Sequential vs Parallel Startup
dateFormat X
axisFormat %L
section Sequential (slow)
DB Service :0, 3
Cache Service :3, 5
Auth Service :5, 6
section Parallel (fast)
DB Service :0, 3
Cache Service :0, 2
Auth Service :0, 1
Perfect for:
- Cold start nightmares: Your Lambda/serverless function times out during initialization
- Dev restart hell: You restart your app 10+ times daily, losing 3+ seconds each time
- Multi-DB apps: PostgreSQL + Redis + S3 + Auth0 = 800ms+ sequential startup pain
- google/wire refugees: You love compile-time DI but hate slow startup times
Quick Start
Install kessoku:
go get -tool github.com/mazrean/kessoku/cmd/kessoku
Create di.go (dependency injection declarations):
package main
import (
"fmt"
"github.com/mazrean/kessoku"
)
type DB struct{ Addr string }
type Cache struct{ Addr string }
func SlowDB() *DB {
// time.Sleep(200 * time.Millisecond)
return &DB{Addr: "db:5432"}
}
func SlowCache() *Cache {
// time.Sleep(150 * time.Millisecond)
return &Cache{Addr: "cache:6379"}
}
//go:generate go tool kessoku $GOFILE
var _ = kessoku.Injectstring),
kessoku.Async(kessoku.Provide(SlowCache)),
kessoku.Provide(func(db DB, cache Cache) string {
return fmt.Sprintf("App running with %s and %s", db.Addr, cache.Addr)
}),
)
Create main.go (application entry point):
package main
import (
"context"
"fmt"
"time"
)
func main() {
start := time.Now()
result := InitApp(context.Background())
fmt.Printf("%s in %v\n", result, time.Since(start))
}
Note: Keep thekessoku.Injectdeclarations and yourmain()function in separate files.
kessoku type-checks the whole package before generating code, so ifmain()callsInitApp
in the same file (or any file) where InitApp is not yet defined, the type-checker will
report undefined: InitApp and no code will be generated — a chicken-and-egg deadlock.
Runninggo generateondi.gofirst producesdi_band.go(which definesInitApp),
after whichgo build/go run .succeeds.
Run:
go generate ./... # generates di_band.go, which defines InitApp
go run .
Shows: App running with db:5432 and cache:6379 in ~200ms (parallel startup)
Installation
Recommended:
go get -tool github.com/mazrean/kessoku/cmd/kessoku
Download binary
Download the latest binary for your platform from the releases page.
Linux/macOS:
# Download and install (replace with your platform)
curl -L -o kessoku.tar.gz https://github.com/mazrean/kessoku/releases/latest/download/kessoku_Linux_x86_64.tar.gz
tar -xzf kessoku.tar.gz
sudo mv kessoku /usr/local/bin/
Windows:
# Download and install
Invoke-WebRequest -Uri "https://github.com/mazrean/kessoku/releases/latest/download/kessoku_Windows_x86_64.zip" -OutFile "kessoku.zip"
Expand-Archive -Path "kessoku.zip" -DestinationPath "."
Move-Item "kessoku.exe" "$env:USERPROFILE\bin\" -Force
Add $env:USERPROFILE\bin to your PATH if not already added
Verify:
kessoku --version
Homebrew (macOS/Linux)
brew install mazrean/tap/kessoku
Other Package Managers
Debian/Ubuntu:
wget https://github.com/mazrean/kessoku/releases/latest/download/kessoku_amd64.deb
sudo apt install ./kessoku_amd64.deb
Red Hat/CentOS/Fedora:
wget https://github.com/mazrean/kessoku/releases/latest/download/kessoku_amd64.rpm
For CentOS/RHEL 7 and older
sudo yum install ./kessoku_amd64.rpm
For CentOS/RHEL 8+ and Fedora
sudo dnf install ./kessoku_amd64.rpm
Alpine Linux:
wget https://github.com/mazrean/kessoku/releases/latest/download/kessoku_amd64.apk
sudo apk add --allow-untrusted kessoku_amd64.apk
Coding Agent Integration
Kessoku provides built-in skills for AI coding assistants to help you write better DI code.
Install skills for your coding agent:
go tool kessoku llm-setup <agent>
Supported agents: Claude Code(claude-code), OpenAI Codex(openai-codex), Cursor(cursor), GitHub Copilot(github-copilot), Gemini CLI(gemini-cli), OpenCode(opencode), Amp(amp), Goose(goose), Factory(factory)
Installation Options
# Install to user-level directory (available across all projects)
go tool kessoku llm-setup <agent> --user
Install to custom directory
go tool kessoku llm-setup <agent> --path ./custom/path
Default installation paths:
- Claude Code:
.claude/skills/(project) or~/.claude/skills/(user) - Cursor:
.cursor/rules/(project) or~/.cursor/rules/(user) - GitHub Copilot:
.github/skills/(project) or~/.github/skills/(user) - Gemini CLI:
.gemini/skills/(project) or~/.gemini/skills/(user) - OpenCode:
.opencode/skill/(project) or~/.config/opencode/skill/(user) - OpenAI Codex:
.codex/skills/(project) or~/.codex/skills/(user) - Amp:
.agents/skills/(project) or~/.config/agents/skills/(user) - Goose:
.agents/skills/(project) or~/.config/goose/skills/(user) - Factory:
.factory/skills/(project) or~/.factory/skills/(user)
Once installed, your coding agent will understand kessoku patterns and can help you:
- Write providers and injectors correctly
- Set up parallel initialization with
Async - Migrate from google/wire
- Troubleshoot code generation issues
API Reference
Full docs: pkg.go.dev/github.com/mazrean/kessoku
Examples: examples/ - basic, async_parallel, sets
kessoku.Async(provider)- Make this provider run in parallelkessoku.Provide(fn)- Regular provider (sequential)kessoku.InjectT- Generate the injector functionkessoku.Set(...)- Group providers for reusekessoku.Value(val)- Inject constantskessoku.BindInterface- Interface → implementation
Migrating from google/wire
Already using google/wire? Kessoku provides a migration tool to convert your wire configuration files automatically.
Quick Migration
# on wire config directory
go tool kessoku migrate
or specify wire config directory with patterns
go tool kessoku migrate ./pkg/wire -o ./pkg/wire/kessoku.go
Advanced Migration Options
Usage: kessoku migrate [<patterns> ...] [flags]
Migrate wire config to kessoku
Arguments:
[<patterns> ...] Go package patterns to migrate
Flags:
-h, --help Show context-sensitive help.
-l, --log-level="info" Log level
-v, --version Show version and exit.
-o, --output="kessoku.go" Output file path
Example
Before (wire.go):
//go:build wireinject
package main
import "github.com/google/wire"
func InitializeApp() (*App, error) {
wire.Build(
NewApp,
NewPostgresRepo,
wire.Bind(new(Repository), new(*PostgresRepo)),
)
return nil, nil
}
After (kessoku.go):
//go:generate go tool kessoku $GOFILE
package main
import "github.com/mazrean/kessoku"
var _ = kessoku.Inject*App,
kessoku.BindRepository),
)
vs Alternatives
| | Kessoku | google/wire | uber-go/dig | |---|---------|-------------|---------| | Startup Speed | Parallel | Sequential | Sequential + runtime | | Learning Curve | Minimal | Minimal | Steep | | Production Ready | Yes | Yes | Yes |
Choose Kessoku if: You have multiple slow services (DB, cache, APIs) and startup time matters Choose google/wire if: You want maximum simplicity and startup speed isn't critical Choose uber/fx if: You need complex lifecycle management and don't mind runtime overhead
Supports
This project receives support from GMO FlattSecurity's “GMO Open Source Developer Support Program” and regularly conducts security assessments using “Takumi byGMO.”