This is a simple RESTful API service. In the code, we are using dependency injection (DI) to load and initialize dependencies when starting the application.
3 ways to inject dependencies:
- No DI framework - Basic DI implemented using Go, no third-party DI framework.
- The Dig framework - Use the Dig framework to inject dependencies at runtime. See the example for details.
- The Wire framework - Use the Wire framework to generate the DI code at compile time. See [the example] (cmd/wire) for details.
-
Install the third party packages.
$ make install
-
You can run of the following targets corresponding to a DI framework.
$ make run-no-framework $ make run-dig $ make run-wire
-
On another shell.
$ curl localhost:8000