Skip to content

Instantly share code, notes, and snippets.

@Brethel
Last active July 3, 2020 23:36
Show Gist options
  • Save Brethel/084db0eb01dacacedff8c0ca9ab82c0b to your computer and use it in GitHub Desktop.
Save Brethel/084db0eb01dacacedff8c0ca9ab82c0b to your computer and use it in GitHub Desktop.
PID = /tmp/awesome-golang-project.pid
GO_FILES = $(wildcard *.go)
APP = ./app
serve: restart
@fswatch -o . | xargs -n1 -I{} make restart || make kill
kill:
@kill `cat $(PID)` || true
before:
@echo "actually do nothing"
$(APP): $(GO_FILES)
@go build $? -o $@
restart: kill before $(APP)
@app & echo $$! > $(PID)
.PHONY: serve restart kill before # let's go to reserve rules names
@Brethel
Copy link
Author

Brethel commented Jul 3, 2020

$ brew install fswatch # if you don't have
$ make serve

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment