Skip to content

Commit

Permalink
add "fmt-check" make target
Browse files Browse the repository at this point in the history
  • Loading branch information
6543 committed Jul 13, 2021
1 parent 1a86fcd commit 1b5510c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# all: Builds the code locally after testing
#
# fmt: Formats the source files
# fmt-check: Check if the source files are formated
# build: Builds the code locally
# vet: Vets the code
# lint: Runs lint over the code (you do not need to fix everything)
Expand All @@ -11,6 +12,9 @@
#
# install: Builds, tests and installs the code locally

GO_PACKAGES ?= $(shell go list ./... | grep -v /vendor/)
GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./.git/*")

.PHONY: all fmt build vet lint test cover install

# The first target is always the default action if `make` is called without
Expand All @@ -19,7 +23,10 @@
all: fmt vet test install

fmt:
@gofmt -s -w ./$*
@gofmt -s -w ${GOFILES_NOVENDOR}

fmt-check:
@([ -z "$(shell gofmt -d $(GOFILES_NOVENDOR) | head)" ]) || (echo "Source is unformatted"; exit 1)

build:
@go build
Expand Down

0 comments on commit 1b5510c

Please sign in to comment.