Created
August 23, 2017 13:23
-
-
Save kron4eg/6b994f985a8333dccb24c6930b1f6b79 to your computer and use it in GitHub Desktop.
boilerplate golang Makefile
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
GOPATH?=$(shell go env GOPATH) | |
export PATH := $(GOPATH)/bin:$(PATH) | |
NOW := $(shell date -u +%Y-%m-%dT%H:%MZ) | |
GITCOMMIT?=$(shell git describe --always) | |
VERSION?=$(NOW)-$(GITCOMMIT)-dev | |
PKG_LIST = $(shell go list ./... | grep -v /vendor/) | |
all: install | |
.PHONY: help | |
help: ## print this help | |
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' | |
install: ## install into $GOPATH/bin | |
go install -v | |
.PHONY: test | |
test: vet lint ## run tests | |
go test $(PKG_LIST) | |
.PHONY: race | |
race: vet lint ## run tests with racedetector | |
go test -race $(PKG_LIST) | |
.PHONY: vet | |
vet: ## vet sources | |
go vet $(PKG_LIST) | |
.PHONY: lint | |
lint: $(GOPATH)/bin/golint ## lint sources | |
golint -set_exit_status -min_confidence=0.4 $(PKG_LIST) | |
.PHONY: doc | |
doc: ## run godoc server on http://localhost:6060/pkg | |
godoc -http=":6060" | |
.PHONY: dep | |
dep: ## ensure dependencies are met | |
dep ensure -v && dep prune && find ./vendor -name '*_test.go' -delete | |
.PHONY: depupdate | |
depupdate: ## update dependencies | |
dep ensure -v -update $(PKG) && dep prune && find ./vendor -name '*_test.go' -delete | |
$(GOPATH)/bin/golint: | |
go get -u github.com/golang/lint/golint |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment