-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
46 lines (36 loc) · 1.27 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
.DEFAULT_GOAL := help
PKGNAME = github.com/maxpoletaev/van
BENCHNAME ?= .
GO = go
.PHONY: help
help:
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| sed -n 's/^\(.*\): \(.*\)## \(.*\)/\1;\3/p' \
| column -t -s ';'
.PHONY: test
test: ## run go tests
$(GO) test -v -race -timeout 30s
.PHONY: bench
bench: ## run benchmarks
$(GO) test -bench=$(BENCHNAME) -run=^$$ -benchmem
.PHONY: benchprof
benchprof: ## run benchmarks with profiling
$(GO) test -bench=$(BENCHNAME) -run=^$$ -benchmem -cpuprofile=cpu.pprof -memprofile=mem.pprof
.PHONY: benchcmp
benchcmp: ## run benchmarks and compare with the previous benchcmp run
$(GO) test -bench=$(BENCHNAME) -run=^$$ -benchmem > bench.txt
@benchcmp bench.old.txt bench.txt
.PHONY: newbenchcmp
newbenchcmp: ## run benchmarks and create new compare file
$(GO) test -bench=$(BENCHNAME) -run=^$$ -benchmem > bench.old.txt
@cat bench.old.txt
.PHONY: godoc
godoc: ## start godoc server at :8000
@(sleep 1; open http://localhost:8000/pkg/$(PKGNAME)) &
@godoc -http=127.0.0.1:8000
.PHONY: lint
lint: ## run linter
golangci-lint run --enable gofmt,unparam,prealloc,gosec,nilerr,errcheck,gosimple,wsl
.PHONY: escape
escape: ## run escape analysis
go test -run=^$$ -gcflags="-m" 2>&1 | grep -Ev '(_test\.go|\$$GOROOT|<autogenerated>)'