A lightweight Go package for managing application initialization order with dependency injection support.
- Register components with custom initialization order
- Thread-safe shared state management
- Automatic lifecycle management (Booting/Booted phases)
- Predefined order constants for common components
package main
type Database struct{}
func (d *Database) Booting() {
// Initialize database connection
}
func (d *Database) Booted() {
// Run migrations or post-init tasks
}
func main() {
db := &Database{}
bootstrapper.Register(db, bootstrapper.OrderDB)
bootstrapper.StartBooting()
bootstrapper.StartBooted()
}const CustomOrder = 50
service := &MyService{}
bootstrapper.Register(service, CustomOrder)// Store shared data
bootstrapper.Share("config", myConfig)
// Retrieve shared data
config := bootstrapper.Get("config")OrderConfig(1) - ConfigurationOrderDB(2) - DatabaseOrderCache(3) - CacheOrderQueue(4) - QueueWorkerPool(5) - Worker PoolOrderRepository(6) - RepositoryOrderService(7) - ServiceOrderController(8) - Controller
go test -vMIT