本站源代码
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

83 lines
1.8KB

  1. .PHONY: default install build test quicktest fmt vet lint
  2. # List of all release tags "supported" by our current Go version
  3. # E.g. ":go1.1:go1.2:go1.3:go1.4:go1.5:go1.6:go1.7:go1.8:go1.9:go1.10:go1.11:go1.12:"
  4. GO_RELEASE_TAGS := $(shell go list -f ':{{join (context.ReleaseTags) ":"}}:' runtime)
  5. # Only use the `-race` flag on newer versions of Go (version 1.3 and newer)
  6. ifeq (,$(findstring :go1.3:,$(GO_RELEASE_TAGS)))
  7. RACE_FLAG :=
  8. else
  9. RACE_FLAG := -race -cpu 1,2,4
  10. endif
  11. # Run `go vet` on Go 1.12 and newer. For Go 1.5-1.11, use `go tool vet`
  12. ifneq (,$(findstring :go1.12:,$(GO_RELEASE_TAGS)))
  13. GO_VET := go vet \
  14. -atomic \
  15. -bool \
  16. -copylocks \
  17. -nilfunc \
  18. -printf \
  19. -rangeloops \
  20. -unreachable \
  21. -unsafeptr \
  22. -unusedresult \
  23. .
  24. else ifneq (,$(findstring :go1.5:,$(GO_RELEASE_TAGS)))
  25. GO_VET := go tool vet \
  26. -atomic \
  27. -bool \
  28. -copylocks \
  29. -nilfunc \
  30. -printf \
  31. -shadow \
  32. -rangeloops \
  33. -unreachable \
  34. -unsafeptr \
  35. -unusedresult \
  36. .
  37. else
  38. GO_VET := @echo "go vet skipped -- not supported on this version of Go"
  39. endif
  40. default: fmt vet lint build quicktest
  41. install:
  42. go get -t -v ./...
  43. build:
  44. go build -v ./...
  45. test:
  46. go test -v $(RACE_FLAG) -cover ./...
  47. quicktest:
  48. go test ./...
  49. # Capture output and force failure when there is non-empty output
  50. fmt:
  51. @echo gofmt -l .
  52. @OUTPUT=`gofmt -l . 2>&1`; \
  53. if [ "$$OUTPUT" ]; then \
  54. echo "gofmt must be run on the following files:"; \
  55. echo "$$OUTPUT"; \
  56. exit 1; \
  57. fi
  58. vet:
  59. $(GO_VET)
  60. # https://github.com/golang/lint
  61. # go get github.com/golang/lint/golint
  62. # Capture output and force failure when there is non-empty output
  63. # Only run on go1.5+
  64. lint:
  65. @echo golint ./...
  66. @OUTPUT=`command -v golint >/dev/null 2>&1 && golint ./... 2>&1`; \
  67. if [ "$$OUTPUT" ]; then \
  68. echo "golint errors:"; \
  69. echo "$$OUTPUT"; \
  70. exit 1; \
  71. fi
上海开阖软件有限公司 沪ICP备12045867号-1