Makefile 1.3 KB

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