-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
81 lines (50 loc) · 2.54 KB
/
Copy pathMakefile
File metadata and controls
81 lines (50 loc) · 2.54 KB
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
.DEFAULT_GOAL := help
SHELL := /bin/bash
BIN_DIR ?= /usr/local/bin
ARCHI = x86_64
VERSION := $(shell git describe --tags --abbrev=0 2> /dev/null || git rev-parse --abbrev-ref HEAD)
REVISION := $(shell git rev-parse HEAD)
BUILD_SETTING := GOOS=linux GOARCH=amd64
BUILD_OPTS := -ldflags="-s -w -X \"main.Version=$(VERSION)\" -X \"main.Revision=$(REVISION)\""
# BUILD_STATIC_OPTS := -a -tags netgo -installsuffix netgo -ldflags="-s -w -X \"main.Version=$(VERSION)\" -X \"main.Revision=$(REVISION)\" -extldflags \"-static\""
gomodule: ## Tidy up Golang dependencies, see https://github.com/golang/go/wiki/Modules
@go mod tidy
gomodule-upgradable: ## List to view available minor and patch upgrades only for the direct dependencies
@go list -u -f '{{if (and (not (or .Main .Indirect)) .Update)}}{{.Path}}: {{.Version}} -> {{.Update.Version}}{{end}}' -m all 2> /dev/null
gomodule-upgrade: ## Upgrade to use the latest minor or patch releases (and add -t to also upgrade test dependencies)
go get -u ./...
gomodule-upgrade-patch: ## Upgrade to use the latest patch releases (and add -t to also upgrade test dependencies)
go get -u=patch ./...
modelgen: ## Generate Golang model definition
@go install github.com/volatiletech/sqlboiler/v4
@go install github.com/volatiletech/sqlboiler/v4/drivers/sqlboiler-mysql
@rm -rf pkg/data/model/apimodel/*.go
sqlboiler -c sqlboiler.toml mysql
mockgen: ## Generate Golang repository mock definition
@go install go.uber.org/mock/mockgen
find server pkg cmd -type d -name "mock" | xargs rm -rf
go generate `go list ./... | grep -v 'mock'`
make format
format: ## Run go formater
@go install golang.org/x/tools/cmd/goimports 2> /dev/null
@go install github.com/sqs/goreturns 2> /dev/null
# @make format-target target="cmd/" &
@make format-target target="server/" &
@make format-target target="pkg/"
format-target: ## Run go formater: ${target}
goimports -w ${target}
goreturns -w ${target}
build: ## Build all of binaries
export BUILD_OPTS='$(BUILD_OPTS)' ;\
./.build.sh
run-air: ## Launch a grpc server by air
( go install github.com/cosmtrek/air@latest && \
export ABCDEFG='some some some' ;\
export HIJKLMN='some some some' ;\
air -c .air.toml \
) || (cd server && go run *.go)
run: | run-air ## Launch a grpc server
run-manually: ## Launch a grpc server, use `go run *.go`
cd server && go run *.go
help: ## Show all of tasks
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'