Last active
August 29, 2015 14:02
-
-
Save bradberger/e62bdb4059da99d64263 to your computer and use it in GitHub Desktop.
A sample Gulpfile for use with any Go HTTP server to automatically recompile the Go binary when any file changes.Adjust the projectName and srcDir to match your project's layout. Tested on Linux (Ubuntu) but should work wherever "sh" is available.
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
var projectName = 'main', | |
srcDir = './src', | |
gulp = require('gulp'), | |
exec = require('gulp-exec'); | |
gulp.task('serve', function() { | |
var opts = { continueOnError: true, pipeStdout: true }, | |
goCmd = 'sh -c "go run ' + __dirname + '/src/*.go&"', | |
killCmd = 'killall -q go ' + projectName; | |
gulp.src(srcDir + '/**/*.go') | |
.pipe(exec(killCmd, opts)) | |
.pipe(exec(goCmd, opts)); | |
}); | |
gulp.task('watch', function() { | |
gulp.watch('./**/*.go', ['serve']); | |
}); | |
gulp.task('default', ['serve', 'watch']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment