-
-
Save v-bus/4128d1812078e48115e47d50eacfa129 to your computer and use it in GitHub Desktop.
Golang Makefile example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OUT := binariy-name | |
PKG := gitlab.com/group/project | |
VERSION := $(shell git describe --always --long --dirty) | |
PKG_LIST := $(shell go list ${PKG}/... | grep -v /vendor/) | |
GO_FILES := $(shell find . -name '*.go' | grep -v /vendor/) | |
all: run | |
server: | |
go build -i -v -o ${OUT} -ldflags="-X main.version=${VERSION}" ${PKG} | |
test: | |
@go test -short ${PKG_LIST} | |
vet: | |
@go vet ${PKG_LIST} | |
lint: | |
@for file in ${GO_FILES} ; do \ | |
golint $$file ; \ | |
done | |
static: vet lint | |
go build -i -v -o ${OUT}-v${VERSION} -tags netgo -ldflags="-extldflags \"-static\" -w -s -X main.version=${VERSION}" ${PKG} | |
run: server | |
./${OUT} | |
clean: | |
-@rm ${OUT} ${OUT}-v* | |
.PHONY: run server static vet lint |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment