defrian8/minidi — reverse-engineered prompt
Reverse engineered prompt
Build me a small Go package called minidi that makes dependency injection feel simple. I want to register services by name, then have those dependencies injected into exported struct fields using a struct tag like di:"logger" instead of wiring everything through long constructors.
It should stay lightweight and framework agnostic, no code generation, just reflection based field injection for small to medium apps. Please support starting the container so it resolves dependencies and automatically calls optional OnStart methods, and stopping it so optional OnStop methods run too. I also want an easy way to get a registered service back by its ID, plus a panic on error helper for registration.
Please make sure it works with concrete types and interfaces, as long as the field is exported. Keep the API minimal and readable. Add a simple example with something like a logger, repository, and service so it is easy to understand, and include a few tests to cover registration, injection, lifecycle hooks, and failure cases. You can look up current Go docs if needed.
Want more depth? Deep Reverse