SOURCES = $(wildcard *.go) $(wildcard **/*.go) OUT=my-log GOBIN=$(shell go env GOBIN) COVEROUT=cover.out COVERHTML=cover.html .PHONY: help help: ## Show help for documented recipes @echo "Make recipes:" @echo @grep -E '^[a-zA-Z0-9_#-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' .PHONY: clean clean: ## Removes temporary and build files rm -v $(COVEROUT) $(COVERHTML) $(OUT) || true .PHONY: fmt ## Runs go fmt fmt: $(SOURCES) ## Runs go fmt go fmt ./... .PHONY: test test: ## Test application and generate coverage report $(MAKE) clean $(MAKE) $(COVEROUT) $(COVEROUT): $(SOURCES) fmt go test ./... -race -cover -coverprofile $@ $(COVERHTML): $(COVEROUT) go tool cover -html=$< -o $@ .PHONY: report report: $(COVERHTML) ## Generate a coverage report .PHONY: open-report open-report: report ## Open the coverage report in the default browser xdg-open $(COVERHTML) .PHONY: build build: $(OUT) ## Builds the application $(OUT): $(SOURCES) fmt go build -o $@