另客网go项目公用的代码库

Makefile 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. GOFMT ?= gofmt "-s"
  2. PACKAGES ?= $(shell go list ./... | grep -v /vendor/)
  3. VETPACKAGES ?= $(shell go list ./... | grep -v /vendor/ | grep -v /examples/)
  4. GOFILES := $(shell find . -name "*.go" -type f -not -path "./vendor/*")
  5. all: install
  6. install: deps
  7. govendor sync
  8. .PHONY: test
  9. test:
  10. sh coverage.sh
  11. .PHONY: fmt
  12. fmt:
  13. $(GOFMT) -w $(GOFILES)
  14. .PHONY: fmt-check
  15. fmt-check:
  16. # get all go files and run go fmt on them
  17. @diff=$$($(GOFMT) -d $(GOFILES)); \
  18. if [ -n "$$diff" ]; then \
  19. echo "Please run 'make fmt' and commit the result:"; \
  20. echo "$${diff}"; \
  21. exit 1; \
  22. fi;
  23. vet:
  24. go vet $(VETPACKAGES)
  25. deps:
  26. @hash govendor > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  27. go get -u github.com/kardianos/govendor; \
  28. fi
  29. @hash embedmd > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  30. go get -u github.com/campoy/embedmd; \
  31. fi
  32. embedmd:
  33. embedmd -d *.md
  34. .PHONY: lint
  35. lint:
  36. @hash golint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  37. go get -u github.com/golang/lint/golint; \
  38. fi
  39. for PKG in $(PACKAGES); do golint -set_exit_status $$PKG || exit 1; done;
  40. .PHONY: misspell-check
  41. misspell-check:
  42. @hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  43. go get -u github.com/client9/misspell/cmd/misspell; \
  44. fi
  45. misspell -error $(GOFILES)
  46. .PHONY: misspell
  47. misspell:
  48. @hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
  49. go get -u github.com/client9/misspell/cmd/misspell; \
  50. fi
  51. misspell -w $(GOFILES)