Registry / utility / sarulabs-di

sarulabs-di

JSON →
library2.0.0+incompatiblegogounverified

A dependency injection container for Go applications.

go get github.com/sarulabs/di
INSTALL
IMPORT
SIG · SARULABS-DI
S
sarulabs-di
utilitygov2.0.0+incompatible
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

di
github.com/sarulabs/di

Creates a DI container, registers a service, and retrieves it.

package main import ( "fmt" "github.com/sarulabs/di" ) func main() { container, _ := di.New() container.Register(di.Def{ Name: "greeter", Build: func(ctn di.Container) (interface{}, error) { return "Hello, World!", nil }, }) greeter, _ := container.Get("greeter") fmt.Println(greeter.(string)) }
Debug
Known issues
breakingVersion 2.0.0+incompatible uses a different import path than v1; ensure you use the correct module path.
fix
Use 'github.com/sarulabs/di' for v2 (note the 'v2' tag) or 'gopkg.in/sarulabs/di.v1' for v1.
affects: >=2.0.0
Upgrade
Version history
2.0.0+incompatiblelatest on pkg.go.dev
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
sarulabs-di — go get sarulabs-di · libregistry