-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
96 lines (79 loc) · 3.03 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
SHELL = /bin/sh
PROJECT = "hq-go-url"
# ------------------------------------------------------------------------------------------------------------------------------
# --- Prepare | Setup ----------------------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------------------------------------------------
.PHONY: prepare
prepare:
@# Install the latest version of Lefthook (a Git hooks manager) and set it up.
go install github.com/evilmartians/lefthook@latest && lefthook install
# ------------------------------------------------------------------------------------------------------------------------------
# --- Go (Golang) --------------------------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------------------------------------------------
GOCMD=go
GOCLEAN=$(GOCMD) clean
GOMOD=$(GOCMD) mod
GOGET=$(GOCMD) get
GOFMT=$(GOCMD) fmt
GOTEST=$(GOCMD) test
GOFLAGS := -v
LDFLAGS := -s -w
ifneq ($(shell go env GOOS),darwin)
LDFLAGS := -extldflags "-static"
endif
GOLANGCILINTCMD=golangci-lint
GOLANGCILINTRUN=$(GOLANGCILINTCMD) run
.PHONY: go-mod-clean
go-mod-clean:
$(GOCLEAN) -modcache
.PHONY: go-mod-tidy
go-mod-tidy:
$(GOMOD) tidy
.PHONY: go-mod-update
go-mod-update:
@# Update test dependencies.
$(GOGET) -f -t -u ./...
@# Update all other dependencies.
$(GOGET) -f -u ./...
.PHONY: go-generate
go-generate:
$(GOCMD) generate ./...
.PHONY: go-fmt
go-fmt:
$(GOFMT) ./...
.PHONY: go-lint
go-lint: go-fmt
$(GOLANGCILINTRUN) $(GOLANGCILINT) ./...
.PHONY: go-test
go-test:
$(GOTEST) $(GOFLAGS) ./...
# ------------------------------------------------------------------------------------------------------------------------------
# --- Help ---------------------------------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------------------------------------------------
.PHONY: help
help:
@echo ""
@echo "*****************************************************************************"
@echo ""
@echo "PROJECT : $(PROJECT)"
@echo ""
@echo "*****************************************************************************"
@echo ""
@echo "Available commands:"
@echo ""
@echo " Preparation | Setup:"
@echo " prepare .................. prepare repository."
@echo ""
@echo " Go Commands:"
@echo " go-mod-clean ............. Clean Go module cache."
@echo " go-mod-tidy .............. Tidy Go modules."
@echo " go-mod-update ............ Update Go modules."
@echo " go-generate .............. Run Go generate."
@echo " go-fmt ................... Format Go code."
@echo " go-lint .................. Lint Go code."
@echo " go-test .................. Run Go tests."
@echo ""
@echo " Help Commands:"
@echo " help ..................... Display this help information"
@echo ""
.DEFAULT_GOAL = help