Skip to content

Instantly share code, notes, and snippets.

@caiguanhao
Created October 4, 2014 03:18
Show Gist options
  • Save caiguanhao/746baadbc26a57ea4b1d to your computer and use it in GitHub Desktop.
Save caiguanhao/746baadbc26a57ea4b1d to your computer and use it in GitHub Desktop.
watch go (golang) file changes and restart it (esp. for server app)
watchgo() {
eval "$@ &; lastpid=\$\!;"; \
fswatch -0 *.go | while read -d ""; \
do pkill -P $lastpid; \
eval "$@ &; lastpid=\$\!;"; \
done
}
# watchgo "go run *.go"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment