Skip to content

Instantly share code, notes, and snippets.

@capoferro
Last active August 29, 2015 14:05
Show Gist options
  • Save capoferro/10036e573331e7143c6b to your computer and use it in GitHub Desktop.
Save capoferro/10036e573331e7143c6b to your computer and use it in GitHub Desktop.
fmt_targetfile:=.gofmt
build: check_format
check_format: $(fmt_targetfile)
@if [[ `cat $(fmt_targetfile)` != "" ]]; then \
echo "These need to be formatted:\n\t$(shell cat $(fmt_targetfile))"; \
exit 1; \
else \
echo 'Good to go!'; \
fi
# fmt_message ensures this regenerates the file every run
$(fmt_targetfile): fmt_message
@gofmt -l $(shell git ls-files | egrep '\.go$') >$@
.PHONY: fmt_message
fmt_message:
@echo "Ensuring .go files are formatted correctly..."
.PHONY: clean
clean:
rm $(fmt_targetfile)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment