dig

command
v1.0.0-beta2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2017 License: MIT Imports: 6 Imported by: 0

README

Dependency Injection Graph Example

This example illustrates how package go.uber.org/fx/dig can be used to inject a dependency.

struct HelloHandler exposes a dependency on hello.Sayer but does not provide any guidance of when or where to get it. On the other side package sayer injects an implementation of hello.Sayer interface into the graph.

When the application is initialized, dig is asked to resolve the dependencies of the HelloHandler and create an instance.

Run the example

$ go build
$ ./dig
$ curl localhost:8080
Well hello there DIG. How are you?

Documentation

Overview

Package main is the Dependency Injection Graph Example.

This example illustrates how package go.uber.org/fx/dig can be used to inject a dependency.

struct HelloHandler exposes a dependency on hello.Sayer but does not provide any guidance of when or where to get it. On the other side package sayer injects an implementation of hello.Sayer interface into the graph.

When the application is initialized, dig is asked to resolve the dependencies of the HelloHandler and create an instance.

Run the example

$ go build
$ ./dig
$ curl localhost:8080
Well hello there DIG. How are you?

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL