()
| 41 | } |
| 42 | |
| 43 | func ExampleC_AddModule_inject() { |
| 44 | type Foo struct { |
| 45 | di.In |
| 46 | Logger log.Logger |
| 47 | } |
| 48 | var f Foo |
| 49 | c := core.New() |
| 50 | c.Provide(di.Deps{func() log.Logger { |
| 51 | return log.NewLogfmtLogger(os.Stdout) |
| 52 | }}) |
| 53 | // If the module embeds di.In (directly or indirectly via pointer), then DI will |
| 54 | // populate its fields. |
| 55 | c.AddModule(&f) |
| 56 | f.Logger.Log("msg", "hello") |
| 57 | // Output: |
| 58 | // msg=hello |
| 59 | } |
| 60 | |
| 61 | func ExampleC_Provide() { |
| 62 | type Foo struct { |