diff --git a/README.md b/README.md index 794aca1..b17ed35 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,24 @@ # DI Dependency injection for Go programming language. -Dependency injection is one form of the broader technique of inversion of control. It is used to increase modularity of the program and make it extensible. \ No newline at end of file +Dependency injection is one form of the broader technique of inversion of control. It is used to increase modularity of the program and make it extensible. + +## Examples +```go +type A struct { + Name string +} + +func NewA() *A { + r := rand.New(rand.NewSource(time.Now().UnixNano())) + name := "A-" + strconv.Itoa(r.Int()) + return &A{Name: ls} +} + +services := NewServiceCollection() +services.AddSingleton(NewA) +serviceProvider := services.Build() + +var env *A +_ = serviceProvider.GetService(&env) // used +``` \ No newline at end of file