在Go中轻松安全地从一种数据类型转换为另一种数据类型
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

39 lines
1.1 KiB

  1. # A Self-Documenting Makefile: http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
  2. .PHONY: check fmt lint test test-race vet test-cover-html help
  3. .DEFAULT_GOAL := help
  4. check: test-race fmt vet lint ## Run tests and linters
  5. test: ## Run tests
  6. go test ./...
  7. test-race: ## Run tests with race detector
  8. go test -race ./...
  9. fmt: ## Run gofmt linter
  10. @for d in `go list` ; do \
  11. if [ "`gofmt -l -s $$GOPATH/src/$$d | tee /dev/stderr`" ]; then \
  12. echo "^ improperly formatted go files" && echo && exit 1; \
  13. fi \
  14. done
  15. lint: ## Run golint linter
  16. @for d in `go list` ; do \
  17. if [ "`golint $$d | tee /dev/stderr`" ]; then \
  18. echo "^ golint errors!" && echo && exit 1; \
  19. fi \
  20. done
  21. vet: ## Run go vet linter
  22. @if [ "`go vet | tee /dev/stderr`" ]; then \
  23. echo "^ go vet errors!" && echo && exit 1; \
  24. fi
  25. test-cover-html: ## Generate test coverage report
  26. go test -coverprofile=coverage.out -covermode=count
  27. go tool cover -func=coverage.out
  28. help:
  29. @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'