Last active
August 16, 2021 13:22
-
-
Save koungkub/f37b60d1020dc2b4fd688a55e4e62307 to your computer and use it in GitHub Desktop.
Nodemon for golang
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
# Inspire by -> https://medium.com/@olebedev/live-code-reloading-for-golang-web-projects-in-19-lines-8b2e8777b1ea | |
PID = /tmp/nodemon-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 "\nRESTARTED ..." | |
$(APP): $(GO_FILES) | |
@go build -o $@ | |
restart: kill before $(APP) | |
@$(APP) & echo $$! > $(PID) | |
.PHONY: serve restart kill before |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment