1+ GO ?= go
2+ GOFMT ?= gofmt "-s"
3+ PACKAGES ?= $(shell $(GO ) list ./... | grep -v /vendor/)
4+ VETPACKAGES ?= $(shell $(GO ) list ./... | grep -v /vendor/ | grep -v /examples/)
5+ GOFILES := $(shell find . -name "* .go" -type f -not -path "./vendor/* ")
6+ TESTFOLDER := $(shell $(GO ) list ./... | grep -v /vendor/ | grep -v examples)
7+
8+ all : install
9+
10+ install : deps
11+ govendor sync
12+
13+ .PHONY : test
14+ test :
15+ echo " mode: atomic" > coverage.out
16+ for d in $( TESTFOLDER) ; do \
17+ $(GO ) test -v -covermode=atomic -coverprofile=profile.out $$ d > tmp.out; \
18+ cat tmp.out; \
19+ if grep -q " ^--- FAIL" tmp.out; then \
20+ rm tmp.out; \
21+ exit 1; \
22+ elif grep -q " build failed" tmp.out; then \
23+ rm tmp.out; \
24+ exit 1; \
25+ elif grep -q " setup failed" tmp.out; then \
26+ rm tmp.out; \
27+ exit 1; \
28+ fi ; \
29+ if [ -f profile.out ]; then \
30+ cat profile.out | grep -v " mode:" >> coverage.out; \
31+ rm profile.out; \
32+ fi ; \
33+ done
34+
35+ .PHONY : fmt
36+ fmt :
37+ $(GOFMT ) -w $(GOFILES )
38+
39+ .PHONY : fmt-check
40+ fmt-check :
41+ @diff=$$($(GOFMT ) -d $(GOFILES ) ) ; \
42+ if [ -n " $$ diff" ]; then \
43+ echo " Please run 'make fmt' and commit the result:" ; \
44+ echo " $$ {diff}" ; \
45+ exit 1; \
46+ fi ;
47+
48+ vet :
49+ $(GO ) vet $(VETPACKAGES )
50+
51+ deps :
52+ @hash govendor > /dev/null 2>&1 ; if [ $$ ? -ne 0 ]; then \
53+ $(GO ) get -u github.com/kardianos/govendor; \
54+ fi
55+
56+ .PHONY : lint
57+ lint :
58+ @hash golint > /dev/null 2>&1 ; if [ $$ ? -ne 0 ]; then \
59+ $(GO ) get -u golang.org/x/lint/golint; \
60+ fi
61+ for PKG in $( PACKAGES) ; do golint -set_exit_status $$ PKG || exit 1; done ;
62+
63+ .PHONY : misspell-check
64+ misspell-check :
65+ @hash misspell > /dev/null 2>&1 ; if [ $$ ? -ne 0 ]; then \
66+ $(GO ) get -u github.com/client9/misspell/cmd/misspell; \
67+ fi
68+ misspell -error $(GOFILES )
69+
70+ .PHONY : misspell
71+ misspell :
72+ @hash misspell > /dev/null 2>&1 ; if [ $$ ? -ne 0 ]; then \
73+ $(GO ) get -u github.com/client9/misspell/cmd/misspell; \
74+ fi
75+ misspell -w $(GOFILES )
76+
77+ .PHONY : tools
78+ tools :
79+ go install golang.org/x/lint/golint; \
80+ go install github.com/client9/misspell/cmd/misspell;
0 commit comments