forked from iselegant/cnappdemo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
37 lines (32 loc) · 774 Bytes
/
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
# Golang parameter(gofmt: code formatter, go vet/golist: lint tools)
GOCMD=go
GOFMT=go fmt
GOVET=$(GOCMD) vet
GOLINT=golint
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
BINARY_NAME=main
BINARY_UNIX=$(BINARY_NAME)_unix
BUILD_PATH=.
APP_PATH=.
all:
make validate
make build
make run
# delete debug symbols by golang option -dlflags "-s -w"
build:
$(GOBUILD) -o $(BUILD_PATH)/$(BINARY_NAME) -ldflags "-s -w" $(APP_PATH)/main.go
validate:
$(GOFMT) ./...
$(GOVET) ./...; $(GOLINT) -set_exit_status ./...
$(GOTEST) -v ./...
clean:
rm -f $(BUILD_PATH)/$(BINARY_NAME)
rm -f $(BUILD_PATH)/$(BINARY_UNIX)
run:
$(BUILD_PATH)/$(BINARY_NAME)
# cross-compile for linux
build-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 make build