Skip to content

Instantly share code, notes, and snippets.

@oLaVanBac
Created November 6, 2019 10:01
Show Gist options
  • Save oLaVanBac/6ef942db63526a5eb9a7a5858a37cfaa to your computer and use it in GitHub Desktop.
Save oLaVanBac/6ef942db63526a5eb9a7a5858a37cfaa to your computer and use it in GitHub Desktop.
simple golang live reload
#!/bin/sh
PID=0
stop() {
if ps -p $PID
then
echo "Stopping... $PID"
kill $PID
fi
echo "Stopped"
}
start() {
echo "Starting..."
go build
./$(basename $PWD) &
PID=$!
echo "Started"
}
ctrl_c() {
stop
exit 0
}
trap ctrl_c INT
start
while inotifywait -qr -e modify .
do
stop
start
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment