From 70a6ea375c88080fc2fd369f7285856652fbb3ee Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Wed, 17 Jun 2020 02:14:23 -0400 Subject: [PATCH] add `make gofmt` --- .check-gofmt.sh | 4 ++++ Makefile | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.check-gofmt.sh b/.check-gofmt.sh index 708e86d7..1daa7195 100755 --- a/.check-gofmt.sh +++ b/.check-gofmt.sh @@ -3,6 +3,10 @@ # exclude vendor/ SOURCES="./oragono.go ./irc" +if [ "$1" = "--fix" ]; then + exec gofmt -s -w $SOURCES +fi + if [ -n "$(gofmt -s -l $SOURCES)" ]; then echo "Go code is not formatted correctly with \`gofmt -s\`:" gofmt -s -d $SOURCES diff --git a/Makefile b/Makefile index 75ec479e..748f36e0 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: all install build release capdefs test smoke +.PHONY: all install build release capdefs test smoke gofmt GIT_COMMIT := $(shell git rev-parse HEAD 2> /dev/null) @@ -36,3 +36,6 @@ test: smoke: oragono mkcerts --conf ./default.yaml || true oragono run --conf ./default.yaml --smoke + +gofmt: + ./.check-gofmt.sh --fix