Skip to content

Commit 599e730

Browse files
Makefile: introduce fmt-check phony target
1 parent 96955d7 commit 599e730

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ fmt: $(GOIMPORTS_BIN)
115115
@$(call print, "Formatting source.")
116116
gofmt -l -w -s $(GOFILES_NOVENDOR)
117117

118+
#? fmt-check: Make sure source code is formatted and imports are correct
119+
fmt-check: fmt
120+
@$(call print, "Checking fmt results.")
121+
if test -n "$$(git status --porcelain)"; then echo "code not formatted correctly, please run `make fmt` again!"; git status; git diff; exit 1; fi
122+
118123
#? lint: Lint source
119124
lint: $(LINT_BIN)
120125
@$(call print, "Linting source.")
@@ -142,6 +147,7 @@ tidy-module-check: tidy-module
142147
unit-cover \
143148
unit-race \
144149
fmt \
150+
fmt-check \
145151
lint \
146152
clean
147153

0 commit comments

Comments
 (0)