🛠 Add Makefile
This commit is contained in:
parent
4eb6101e7e
commit
fb6c2fb941
2 changed files with 44 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -122,3 +122,4 @@ Temporary Items
|
||||||
*.icloud
|
*.icloud
|
||||||
|
|
||||||
# End of https://www.toptal.com/developers/gitignore/api/go,linux,emacs,macos
|
# End of https://www.toptal.com/developers/gitignore/api/go,linux,emacs,macos
|
||||||
|
my-log
|
||||||
|
|
|
||||||
43
Makefile
Normal file
43
Makefile
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
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: ## Runs go fmt
|
||||||
|
go fmt ./...
|
||||||
|
|
||||||
|
.PHONY: test
|
||||||
|
test: ## Test application and generate coverage report
|
||||||
|
rm $(COVEROUT) 2>/dev/null || true
|
||||||
|
$(MAKE) $(COVEROUT)
|
||||||
|
|
||||||
|
$(COVEROUT): $(SOURCES)
|
||||||
|
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)
|
||||||
|
go build -o $@
|
||||||
Loading…
Add table
Add a link
Reference in a new issue