File tree 1 file changed +9
-14
lines changed
1 file changed +9
-14
lines changed Original file line number Diff line number Diff line change 1
1
.PHONY : test
2
2
3
+ GOFMT ?= gofmt "-s"
3
4
PACKAGES ?= $(shell go list ./... | grep -v /vendor/)
5
+ GOFILES := find . -name "*.go" -type f -not -path "./vendor/*"
4
6
5
7
install :
6
8
@hash govendor > /dev/null 2>&1 ; if [ $$ ? -ne 0 ]; then \
@@ -15,23 +17,16 @@ embedmd:
15
17
embedmd -d * .md
16
18
17
19
fmt :
18
- find . -name " *.go " -type f -not -path " ./vendor/* " | xargs gofmt -s -w
20
+ $( GOFILES ) | xargs $( GOFMT ) -w
19
21
20
22
.PHONY : fmt-check
21
23
fmt-check :
22
- @if git diff --quiet --exit-code; then \
23
- $(MAKE ) fmt && git diff --exit-code || { \
24
- git checkout . ; \
25
- echo ; \
26
- echo " Please run 'make fmt' and commit the result" ; \
27
- echo ; \
28
- false ; } >&2 ; \
29
- else { \
30
- echo ; \
31
- echo " 'make fmt-check' cannot be run with unstaged changes" ; \
32
- echo ; \
33
- false ; } >&2 ; \
34
- fi
24
+ # get all go files and run go fmt on them
25
+ @files=$$($(GOFILES ) | xargs $(GOFMT ) -l) ; if [ -n " $$ files" ]; then \
26
+ echo " Please run 'make fmt' and commit the result:" ; \
27
+ echo " $$ {files}" ; \
28
+ exit 1; \
29
+ fi ;
35
30
36
31
test : fmt-check
37
32
for PKG in $( PACKAGES) ; do go test -v -cover -coverprofile $$ GOPATH/src/$$ PKG/coverage.txt $$ PKG || exit 1; done ;
You can’t perform that action at this time.
0 commit comments