Maybe you need gin ?
Made by the creator of Martini.
Question
I'm trying out Martini, which adds some nice functionality upon Go's basic net/http
package.
I was wondering tho. How can I, like Django does too, let the server restart itself on source-file changes? I know how to monitor a file, but I'm not sure how to retrigger the Server within the same process.
I'm guessing to trigger http.ListenAndServe
again, but I have a feeling it doesn't go well with instance already running.
Do I need to spawn a subprocess/daemon to get this working?
Solution
Maybe you need gin ?
Made by the creator of Martini.
OTHER TIPS
You may give it a try
Fresh is a command line tool that builds and (re)starts your web application everytime you save a Go or template file.
You'll need to use an external tool that can watch a directory/files and run a command. I'd recommend reflex which is written in Go itself:
(modifying the example in the README):
# Rerun make whenever a .go file changes
reflex -r '\.go$' ./mymartiniapp