-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
47 lines (37 loc) · 1.1 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
PACKAGES=`go list ./... | grep -E -v 'example|proto'`
FORMAT_FILES=`find . -type f -name '*.go' | grep -E -v '_generated.go|.pb.go'`
XGO_OK=$(shell type xgo > /dev/null 2>&1 && echo $$?)
xgo:
@if [ "${XGO_OK}" != "0" ]; then \
echo "installing xgo for unit test"; \
go install github.com/xhd2015/xgo/cmd/xgo@latest; \
fi
tidy:
go mod tidy
cover: tidy
go test -failfast ${PACKAGES} -coverprofile=cover.out -covermode=count
test: tidy
xgo test -race -failfast ${PACKAGES}
report:
@echo ">>>static checking"
@go vet ./...
@echo "done\n"
@echo ">>>detecting ineffectual assignments"
@ineffassign ./...
@echo "done\n"
@echo ">>>detecting icyclomatic complexities over 10 and average"
@gocyclo -over 10 -avg -ignore '_test|vendor' . || true
@echo "done\n"
MOD=$(shell cat go.mod | grep ^module -m 1 | awk '{ print $$2; }' || '')
FILE_LIST=$(shell find . -type f -name '*.go' | grep -E -v '_generated.go|.pb.go')
.PHONY: fmt
fmt:
@echo ${MOD}
@for item in ${FILE_LIST} ; \
do \
if [ -z ${MOD} ]; then \
goimports -d -w $$item ; \
else \
goimports -d -w -local "${MOD}" $$item ; \
fi \
done