You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+31-11Lines changed: 31 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,8 @@
1
-
# do - Dependency Injection
1
+
# DI - Dependency Injection
2
+
3
+
> This is a forked of the original [Do](https://github.com/samber/do) package with an extension to allow dynamically injecting depdencies to a struct through reflection.
This library implements the Dependency Injection design pattern. It may replace the `uber/dig` fantastic package in simple Go projects. `samber/do` uses Go 1.18+ generics and therefore is typesafe.
14
16
15
-
**See also:**
16
-
17
-
-[samber/lo](https://github.com/samber/lo): A Lodash-style Go library based on Go 1.18+ Generics
18
-
-[samber/mo](https://github.com/samber/mo): Monads based on Go 1.18+ Generics (Option, Result, Either...)
19
-
20
-
**Why this name?**
21
-
22
-
I love **short name** for such a utility library. This name is the sum of `DI` and `Go` and no Go package currently uses this name.
23
-
24
17
## 💡 Features
25
18
26
19
- Service registration
@@ -43,6 +36,33 @@ I love **short name** for such a utility library. This name is the sum of `DI` a
43
36
44
37
🛑 Services can be shutdowned properly, in back-initialization order. Services implementing `di.Shutdownable` interface will be called via `di.Shutdown[type]()` or `Container.Shutdown()`.
45
38
39
+
## Di compared to original Do package
40
+
We added a method to allow injecting dependencies dynamically through struct reflection.
41
+
Declare a service, and add a `di:"<name>:` tag to the field where you want the container to inject the corresponding dependency.
0 commit comments