equal
deleted
inserted
replaced
1 # A Self-Documenting Makefile: http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html |
1 GOVERSION := $(shell go version | cut -d ' ' -f 3 | cut -d '.' -f 2) |
2 |
2 |
3 .PHONY: check fmt lint test test-race vet test-cover-html help |
3 .PHONY: check fmt lint test test-race vet test-cover-html help |
4 .DEFAULT_GOAL := help |
4 .DEFAULT_GOAL := help |
5 |
5 |
6 check: test-race fmt vet lint ## Run tests and linters |
6 check: test-race fmt vet lint ## Run tests and linters |
10 |
10 |
11 test-race: ## Run tests with race detector |
11 test-race: ## Run tests with race detector |
12 go test -race ./... |
12 go test -race ./... |
13 |
13 |
14 fmt: ## Run gofmt linter |
14 fmt: ## Run gofmt linter |
|
15 ifeq "$(GOVERSION)" "12" |
15 @for d in `go list` ; do \ |
16 @for d in `go list` ; do \ |
16 if [ "`gofmt -l -s $$GOPATH/src/$$d | tee /dev/stderr`" ]; then \ |
17 if [ "`gofmt -l -s $$GOPATH/src/$$d | tee /dev/stderr`" ]; then \ |
17 echo "^ improperly formatted go files" && echo && exit 1; \ |
18 echo "^ improperly formatted go files" && echo && exit 1; \ |
18 fi \ |
19 fi \ |
19 done |
20 done |
|
21 endif |
20 |
22 |
21 lint: ## Run golint linter |
23 lint: ## Run golint linter |
22 @for d in `go list` ; do \ |
24 @for d in `go list` ; do \ |
23 if [ "`golint $$d | tee /dev/stderr`" ]; then \ |
25 if [ "`golint $$d | tee /dev/stderr`" ]; then \ |
24 echo "^ golint errors!" && echo && exit 1; \ |
26 echo "^ golint errors!" && echo && exit 1; \ |