-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
96 lines (74 loc) · 2.73 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
Branch?=`git rev-parse --abbrev-ref HEAD`
SHA1=`git rev-parse --short HEAD`
Date=`date +%Y-%m-%dT%H:%M:%S`
Version=$(Branch)@$(SHA1)@$(Date)
User=`whoami`@`hostname`
LDFLAGS=-ldflags "-X 'sketch/pkg/version.Version=${Version}' \
-X 'sketch/pkg/version.Revision=${SHA1}' \
-X 'sketch/pkg/version.Branch=${Branch}' \
-X 'sketch/pkg/version.BuildDate=${Date}' \
-X 'sketch/pkg/version.BuildUser=${User}'"
default: build
app:
@echo "\033[32mcurrent build flag version: ${Version}\033[0m"
@go build ${LDFLAGS} -o bin/sketch ./cmd/sketch/sketch.go
@echo "\033[32mbinary file output target at: bin/sketch\033[0m"
app-linux:
@echo "\033[32mcurrent build flag version: ${Version}\033[0m"
@CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build ${LDFLAGS} -o bin/sketch ./cmd/sketch/sketch.go
@echo "\033[32mbinary file output target at: bin/sketch\033[0m"
build: app
run:
@go run cmd/sketch/sketch.go
image:
@make app-linux
@docker build . -t ${TAG}
@docker push ${TAG}
tools:
go get -v github.com/Masterminds/glide
go get -v honnef.co/go/tools/cmd/staticcheck
go get -v honnef.co/go/tools/cmd/gosimple
go get -v honnef.co/go/tools/cmd/unused
go get -v github.com/gordonklaus/ineffassign
go get -v github.com/fzipp/gocyclo
go get -v github.com/golang/lint/golint
go get -v github.com/pierrre/gotestcover
go get -v github.com/client9/misspell/cmd/misspell
go get -v github.com/mfridman/tparse
vet:
@if test -n '$(shell go vet `glide nv` 2>&1 | egrep -v "^vendor\/|.*_easyjson\.go|.*\.pb\.go|^exit\ status")'; then \
echo '$(shell go vet `glide nv` 2>&1 | egrep -v "^vendor\/|.*_easyjson\.go|.*\.pb\.go|^exit\ status")'; \
exit 1; \
fi
lint:
@if test -n '$(shell golint `glide nv` 2>&1 | egrep -v ".*_easyjson\.go|.*\.pb\.go|.*lock_linux\.go")'; then \
echo '$(shell golint `glide nv` 2>&1 | egrep -v ".*_easyjson\.go|.*\.pb\.go|.*lock_linux\.go")'; \
fi
staticcheck:
staticcheck $(shell glide nv)
gosimple:
gosimple $(shell glide nv)
unused:
unused $(shell glide nv)
ineffassign:
@for f in `find . -type d -depth 1 |egrep -v "git|hook|vendor|easyjson\.go"`; do \
ineffassign $$f; \
done
misspell:
misspell $(shell find . -maxdepth 1 -mindepth 1 -type d |egrep -v "^\.$|git|hook|vendor|admin")
misspell $(shell find ./admin -type f -not -path "./admin/web/*")
gocyclo:
@gocyclo -over 20 $(shell find . -name "*.go" |egrep -v "pb\.go|_test\.go|vendor|easyjson\.go")
check: vet lint staticcheck gosimple unused misspell
doc:
godoc -http=:6060
cover:
go test -v -coverprofile=cover.out ./...
go tool cover -html=cover.out
@rm -f cover.out
fmt:
gofmt -s -w .
clean:
@rm -f ./bin/*
@echo "\033[32mclean done\033[0m"
.PHONY: vet clean linux doc fmt build test cover check unused gocyclo gosimple staticcheck rpm upload