I know AppEngine does this, but I\'m not coding for it.
I tried using Guard from Ruby world, to listen on changes on .go files, and execut
After scrolling through the internet in search of a simple solution that was using standard linux tools (inotify & bash), I ended up creating this simple bash script that does the job.
I tested it in a container running golang:1.12 and using go run . to serve files. read the script before using it, as it kills the go run processes depending on a folder name, and if there are conflicts with other processes that you run it might kill them.
#!/bin/bash
go run . &
while inotifywait --exclude .swp -e modify -r . ;
do
# find PID of the file generated by `go run .` to kill it. make sure the grep does not match other processes running on the system
IDS=$(ps ax | grep "/tmp/go-build" | grep "b001/exe/main" | grep -v "grep" | awk '{print $1}')
if [ ! -z "$IDS" ]
then
kill $IDS;
fi
go run . &
done;