Development
Native Development
If you're writing a small project with a few endpoints then running Go in your terminal shouldn't be much of a problem. You can use live-reload while you're editing your code in your favourite editor.
To run the service without building, run go run .
which will achieve the same result as running ./go-boilerplate
after building the binary.
The name go-boilerplate
will change if you change the package name as mentioned here.
In-Docker Development
However, when you are running a large project with multiple micro-services (multiple instances of this boilerplate), it can be handy to live edit your code while in Docker. For this, we have designed the Dockerfile.dev
to get you started.
Simply run make quick-start
to get up and running. To stop it, use Ctrl+C
.
Live Reload
It is convenient to automatically restart the service every time you save your changes. For that, you can use air, which is a separate Go package you can install using the following command:
go install github.com/cosmtrek/air@latest
Once air
is installed, you simply need to run air
to start the service. Configurations for this can be found under ./.air.toml
.
Live reloading will also work in Docker. The Dockerfile.dev
is configured to install and run the service via air
.