Skip to Content

Automatically recompile and restart your Go application

Posted on

I was looking for a way to automatically rebuild my Go project while editing it. I found a a great little tool called CompileDaemon to solve this problem.

It will watch all your *.go files in the current directory and triggers the go build command when something changes.

Install it like this:

go get

To start using it run the following command in your project’s directory:


Now make a change to any of your Go files. CompileDaemon will automatically trigger the go build command as soon as you save the file.

You can also run a command after a successful build. In my case I was working on a small net/http application, so I wanted to restart the server on each update in order to test the changes.

Here’s the command I use to automatically build and restart the server:

CompileDaemon -command="./server"

An excellent little time saver!

comments powered by Disqus