-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
54 lines (46 loc) · 1.15 KB
/
Makefile
File metadata and controls
54 lines (46 loc) · 1.15 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
# Makefile for landers1037/blog
# 2021.7.23
# 使用默认方式动态链接构建
# envs
APP_NAME=app_blog
BUILD_STATIC=-extldflags -static
GO111MODULES=on
CGO_ENABLED=1
GOPROXY=https://goproxy.io,direct
.PHONY: build
## build: build the blog application
build: clean env
@echo "start to build app blog"
go build --mod=mod -a -ldflags="-w -s ${BUILD_STATIC}" -trimpath -tags="nomsgpack go_json" -o ${APP_NAME} app.go
.PHONY: run
## run: run go run app.go with -race
run:
@go run -race app.go
.PHONY: clean
## clean: clean the go binary
clean:
@echo "start to clean the binary"
@go clean --mod=mod
.PHONY: setup
## setup: setup go modules
setup:
@echo "start to download mods"
@go mod tidy \
&& @go mod download
.PHONY: env
## env: setup envs
env:
export GO111MODULES=${GO111MODULES}
export GOPROXY=${GOPROXY}
export CGO_ENABLED=${CGO_ENABLED}
.PHONY: test
## test: make test binary
test: clean
@echo "start to build test app"
go build --mod=mod -a -o app app.go
.PHONY: help
## help: show help usages
help:
@echo "this makefile help you build blog binary"
@echo "Usage: \n"
@sed -n 's/^##/ /p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /'