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