Skip to content

Instantly share code, notes, and snippets.

@bykof
Last active July 3, 2020 12:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bykof/edeafe2320817cd8e4e540a63c0806f7 to your computer and use it in GitHub Desktop.
Save bykof/edeafe2320817cd8e4e540a63c0806f7 to your computer and use it in GitHub Desktop.
package main
import (
"example.com/dingo_example"
"example.com/dingo_example/interfaces"
"flamingo.me/dingo"
"log"
)
func main() {
injector, err := dingo.NewInjector(new(dingo_example.Module))
if err != nil {
panic(err)
}
// Now that we've got the injector, we can build objects.
// We get a new instance, and cast it accordingly:
instance, err := injector.GetInstance(new(interfaces.AppController))
if err != nil {
log.Fatal(err)
}
appController := instance.(*interfaces.AppController)
appController.PrintProducts()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment