Last active
February 14, 2016 18:40
-
-
Save carbocation/5278173 to your computer and use it in GitHub Desktop.
On OS X, use fswatch to automatically recompile your golang project whenever you change a file in the directory.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script keeps watch on the current project and compiles it continuously as you change files. | |
# If there are multiple projects with the same final directory name (e.g., /proj/rad and /lib/monster/rad), | |
# this will kill any other similarly-named running projects' binaries, potentially leading to havoc. | |
# To run, install fswatch, drop this file into your project directory, make it executable, and run: | |
# /usr/local/bin/fswatch ./ ./continuous-compile.sh | |
echo "Re-compiling" | |
#Count the number of times the compiled app is running | |
numproc=`ps aux | grep ${PWD##*/}-main.osx | grep -v grep | wc -l` | |
if [[ numproc > 0 ]] | |
then | |
killall ${PWD##*/}-main.osx 2> /dev/null | |
fi | |
go build -o /tmp/${PWD##*/}-main.osx main.go && /tmp/${PWD##*/}-main.osx & |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment