-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
53 lines (39 loc) · 1.23 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
BINARY_NAME=MCQPlatform
MAIN_FILE = cmd/main.go
COVERAGE_NAME = coverage
# Check that the architecture is set to either OSX or Linux,
# die with an error otherwise.
# The ARCH variable is to be supplied via the make command.
define check_arch
$(if $(filter $(ARCH), darwin linux), \
@echo Architecture set to $(ARCH), \
$(error Please set an ARCH of either "linux" or "darwin"))
endef
build:
$(call check_arch)
GOARCH=amd64 GOOS=$(ARCH) go build -o ${BINARY_NAME}-$(ARCH) $(MAIN_FILE)
run:
./${BINARY_NAME}-${ARCH}
build_and_run: build run
generate:
go generate ./...
swagger:
swag fmt
swag init -d cmd/,pkg/model/cassandra,pkg/model/http,pkg/http/rest -g ../pkg/http/rest/rest.go
clean:
go clean
rm -f ${BINARY_NAME}-darwin ${BINARY_NAME}-linux
test:
go test ./...
test_short:
go test -short ./...
test_no_cache:
go test -count=1 ./...
coverage:
go test ./... -covermode=count -coverprofile ${COVERAGE_NAME}/${COVERAGE_NAME}.out
go tool cover -html ${COVERAGE_NAME}/${COVERAGE_NAME}.out -o ${COVERAGE_NAME}/${COVERAGE_NAME}.html
coverage_report: coverage
open ${COVERAGE_NAME}/${COVERAGE_NAME}.html
dep:
go mod download
.PHONY: build run build_and_run generate swagger clean test test_short test_no_cache coverage coverage_report