-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
57 lines (43 loc) · 1.45 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
CURDIR=$(shell pwd)
BINDIR=${CURDIR}/bin
GOVER=$(shell go version | perl -nle '/(go\d\S+)/; print $$1;')
MOCKGEN=${BINDIR}/mockgen_${GOVER}
SMARTIMPORTS=${BINDIR}/smartimports_${GOVER}
LINTVER=v1.49.0
LINTBIN=${BINDIR}/lint_${GOVER}_${LINTVER}
PACKAGE=github.com/cr00z/goSimpleChat/cmd/server
all: format build test lint
precommit: format build test lint
echo "OK"
format: install-smartimports
${SMARTIMPORTS} -exclude internal/mocks
build: bindir
go build -o ${BINDIR}/server ${PACKAGE}
test:
go test ./...
lint: install-lint
${LINTBIN} run
run: swagger build
${BINDIR}/server
generate: install-mockgen
${MOCKGEN} -source=internal/model/messages/incoming_msg.go -destination=internal/mocks/messages/messages_mocks.go
swagger:
# export PATH=$PATH:$HOME/go/bin
# go install github.com/swaggo/swag/cmd/swag
go get -u github.com/swaggo/swag/cmd/swag
swag init -g cmd/server/main.go
# service
bindir:
mkdir -p ${BINDIR}
install-smartimports: bindir
test -f ${SMARTIMPORTS} || \
(GOBIN=${BINDIR} go install github.com/pav5000/smartimports/cmd/smartimports@latest && \
mv ${BINDIR}/smartimports ${SMARTIMPORTS})
install-lint: bindir
test -f ${LINTBIN} || \
(GOBIN=${BINDIR} go install github.com/golangci/golangci-lint/cmd/golangci-lint@${LINTVER} && \
mv ${BINDIR}/golangci-lint ${LINTBIN})
install-mockgen: bindir
test -f ${MOCKGEN} || \
(GOBIN=${BINDIR} go install github.com/golang/mock/mockgen@v1.6.0 && \
mv ${BINDIR}/mockgen ${MOCKGEN})