-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
72 lines (55 loc) · 1.95 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
-include .env
CURRENT_DIR = $(shell realpath .)
.PHONY: init
init:
@cp .go.work go.work
@find $(realpath .) -name go.mod | xargs dirname | xargs -I {} sh -c 'cd {}; go install -v ./...'
@go install honnef.co/go/tools/cmd/staticcheck@latest
@go install golang.org/x/tools/cmd/godoc@latest
.PHONY: generate
generate:
@find $(realpath .) -name go.mod | xargs dirname | xargs -I {} sh -c 'cd {}; go generate ./...'
.PHONY: build
build:
@go clean -cache
@mkdir -p dist
@cd cmd && go build -ldflags "-s -w" -o ../dist ./...
.PHONY: clean
clean:
@go clean -cache
@rm -rf dist
.PHONY: tidy
tidy:
@find $(realpath .) -name go.mod | xargs dirname | xargs -I {} sh -c 'cd {}; go mod tidy'
.PHONY: update
update:
@find $(realpath .) -name go.mod | xargs dirname | xargs -I {} sh -c 'cd {}; go get -u all && go mod tidy'
.PHONY: sync
sync:
@go work sync
.PHONY: check
check: lint test
.PHONY: test
test:
@find $(realpath .) -name go.mod | xargs dirname | xargs -I {} sh -c 'cd {}; go test -race $(test-options) ./...'
.PHONY: coverage
coverage:
@find $(realpath .) -name go.mod | xargs dirname | xargs -I {} sh -c 'cd {}; go test -race --coverprofile=coverage.out --covermode=atomic $(test-options) ./...'
@find $(realpath .) -name go.mod | xargs dirname | grep '${CURRENT_DIR}/' | xargs -I {} sh -c 'cd {}; cat coverage.out >> '${CURRENT_DIR}/coverage.out' && rm coverage.out'
.PHONY: benchmark
benchmark:
@find $(realpath .) -name go.mod | xargs dirname | xargs -I {} sh -c 'cd {}; go test -run="-" -bench=".*" -benchmem $(test-options) ./...'
.PHONY: lint
lint: fmt vet staticcheck
.PHONY: fmt
fmt:
@find $(realpath .) -name go.mod | xargs dirname | xargs -I {} sh -c 'cd {}; go fmt ./...'
.PHONY: vet
vet:
@find $(realpath .) -name go.mod | xargs dirname | xargs -I {} sh -c 'cd {}; go vet ./...'
.PHONY: staticcheck
staticcheck: init
@find $(realpath .) -name go.mod | xargs dirname | xargs -I {} sh -c 'cd {}; staticcheck ./...'
.PHONY: doc
doc: init
@godoc -http=:6060