Makefile 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. export GO111MODULE=on
  2. default: fmt vet errcheck test lint
  3. # Taken from https://github.com/codecov/example-go#caveat-multiple-files
  4. .PHONY: test
  5. test:
  6. echo "" > coverage.txt
  7. for d in `go list ./...`; do \
  8. go test -p 1 -v -timeout 240s -race -coverprofile=profile.out -covermode=atomic $$d || exit 1; \
  9. if [ -f profile.out ]; then \
  10. cat profile.out >> coverage.txt; \
  11. rm profile.out; \
  12. fi \
  13. done
  14. GOLINT := $(shell command -v golint)
  15. .PHONY: lint
  16. lint:
  17. ifndef GOLINT
  18. go get golang.org/x/lint/golint
  19. endif
  20. go list ./... | xargs golint
  21. .PHONY: vet
  22. vet:
  23. go vet ./...
  24. ERRCHECK := $(shell command -v errcheck)
  25. # See https://github.com/kisielk/errcheck/pull/141 for details on ignorepkg
  26. .PHONY: errcheck
  27. errcheck:
  28. ifndef ERRCHECK
  29. go get github.com/kisielk/errcheck
  30. endif
  31. errcheck -ignorepkg fmt github.com/Shopify/sarama/...
  32. .PHONY: fmt
  33. fmt:
  34. @if [ -n "$$(go fmt ./...)" ]; then echo 'Please run go fmt on your code.' && exit 1; fi
  35. .PHONY : install_dependencies
  36. install_dependencies: get
  37. .PHONY: get
  38. get:
  39. go get -t -v ./...
  40. .PHONY: clean
  41. clean:
  42. go clean ./...