github.com/alecthomas/inject
Package inject provides dependency injection for Go. For small Go applications, manually constructing all required objects is more than sufficient. But for large, modular code bases, dependency injection can alleviate a lot of boilerplate. The following example illustrates a simple modular application. First, the main package installs configured modules and calls an entry point: Next we have a simple Mongo module with a configurable URI: The logging package shows idiomatic use of inject; it is just a thin wrapper around normal Go constructors. This is the least invasive way of using injection, and preferred. Two interfaces to the injector are provided: SafeInjector and Injector. The former will return error values and the latter will panic on any error. The latter is commonly used because DI failures are typically not user-recoverable. See the [README](https://github.com/alecthomas/inject/blob/master/README.md) for more details.
proxy.golang.org
v0.0.0-20180408235619-a9441b76e57f
almost 8 years ago
1
1
Past Dependents
Check this option to include packages that no longer depend on this package in their latest version but previously did.
Filter
Filter by Kind
Links
| Registry | proxy.golang.org |
| Source | Repository |
| Docs | Documentation |
| JSON API | View JSON |
| CodeMeta | codemeta.json |
Package Details
| PURL |
pkg:golang/github.com/alecthomas/inject
spec |
| License | MIT |
| Namespace | github.com/alecthomas |
| First Release | almost 8 years ago |
| Last Synced | 24 days ago |
Repository
| Stars | 28 on GitHub |
| Forks | 0 on GitHub |