-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
49 lines (33 loc) · 1.23 KB
/
Makefile
File metadata and controls
49 lines (33 loc) · 1.23 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
all: build
version := "1.0.0"
dockerName := "reg.huiwang.io/fat/coin-manage"
CURRENT_DIR=$(pwd)
PROJ = coin-manage
MODULE = "coin-manage"
PKG = `go list ./... | grep -v /vendor/`
#print tag into pkg
PKG_TAG = -ldflags "-w -X ${PROJ}/common.gitTag=`git describe --tags` -X ${PROJ}/common.commitNumber=`git rev-parse HEAD` -X ${PROJ}/common.buildTime=`date +%FT%T%z`"
#cross compile
CROSS_COMPILE = CGO_ENABLED=0 GOOS=linux GOARCH=amd64
CILINT := $(shell command -v golangci-lint 2> /dev/null)
GOIMPORTS := $(shell command -v goimports 2> /dev/null)
style:
! find . -path ./vendor -prune -o -name '*.go' -print | xargs goimports -d -local ${MODULE} | grep '^'
format:
ifndef GOIMPORTS
$(error "goimports is not available please install goimports")
endif
find . -path ./vendor -prune -o -name '*.go' -print | xargs goimports -l -local ${MODULE} | xargs goimports -l -local ${MODULE} -w
cilint:
golangci-lint run
clean:
rm -rf bin
build:
go build ${PKG_TAG} -o bin/coin-manage main.go
sudo docker build -t $(dockerName):$(version) .
sudo docker push $(dockerName):$(version)
test: style cilint
go test -cover ./...
server: clean
${CROSS_COMPILE} go build -o bin/linux-amd64-coin-manage ${PKG_TAG} main.go
.PHONY: build clean client