Get started with Fx¶
This introduces you to the basics of Fx. In this tutorial you will:
- start an empty application
 - add an HTTP server to it
 - register a handler with the server
 - add logging to your application
 - refactor to loosen coupling to your handler
 - add another handler to the server
 - generalize your implementation
 
First, get set up for the rest of the tutorial.
- Start a new empty project.
 
mkdir fxdemo
cd fxdemo
go mod init example.com/fxdemo
- Install the latest version of Fx.
 
go get go.uber.org/fx@latest
Now begin by creating a minimal application.