Alice: an additive dependency injection container for Golang

What is a preferable way?

Why a new DI container?

How it works?

type ExampleModule struct {
alice.BaseModule
Foo Foo `alice:""`
Bar Bar `alice:"Bar"`
Baz Baz
}

func (m *ExampleModule) InstanceX() X {
return X{m.Foo}
}

func (m *ExampleModule) InstanceY() Y {
return Y{m.Baz}
}
m1 := &ExampleModule1{}
m2 := &ExampleModule2{...}
container := alice.CreateContainer(m1, m2)
instanceX := container.InstanceByName("InstanceX")instanceY := container.Instance(reflect.TypeOf((Y)(nil)))

Limitations

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store