-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
39 lines (29 loc) · 829 Bytes
/
Makefile
File metadata and controls
39 lines (29 loc) · 829 Bytes
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
PKG := $(shell head -1 go.mod | sed -e 's/module //')
OUT := $(shell basename ${PKG})
VERSION := $(shell git describe --tag --long --dirty)
PKG_LIST := $(shell go list ${PKG}/...)
GO_FILES := $(shell find . -name '*.go')
all: build
build:
go build -v -o ${OUT} -ldflags="-X main.version=${VERSION}" ${PKG}
c.out:
go test -coverprofile=c.out -v ${PKG}/...
test: c.out
coverhtml: test
go tool cover -html=c.out
vet:
@go vet ${PKG_LIST}
lint:
@for file in ${GO_FILES} ; do \
golint $$file ; \
done
static: vet lint
go build -v -o ${OUT}-${VERSION} -a \
-tags netgo \
-gcflags=all=-trimpath=${GOPATH} \
-asmflags=all=-trimpath=${GOPATH} \
-ldflags="-extldflags \"-static\" -w -s -X main.version=${VERSION}" \
${PKG}
clean:
rm -f ${OUT} ${OUT}-v* c.out
.PHONY: build test coverhtml vet lint static clean