Created
March 7, 2015 00:57
-
-
Save smagch/f1130e3ed5b62ef42e56 to your computer and use it in GitHub Desktop.
Makefile for Golang project that has multiple packages
This file contains hidden or 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
GO_LINT = ${GOPATH}/bin/golint | |
GO_VET = ${GOPATH}/bin/vet | |
# set your packages. | |
TARGETS = foo bar hoge | |
TARGETS_TEST = $(patsubst %,test-%, $(TARGETS)) | |
TARGETS_LINT = $(patsubst %,lint-%, $(TARGETS)) | |
TARGETS_VET = $(patsubst %,vet-%, $(TARGETS)) | |
.PHONY: test lint vet $(TARGETS_TEST) $(TARGETS_LINT) | |
$(GO_LINT): | |
go get -u github.com/golang/lint/golint | |
$(GO_VET): | |
go get -u golang.org/x/tools/cmd/vet | |
test: $(TARGETS_TEST) | |
# @godep go test | |
$(TARGETS_TEST): test-%: % | |
@cd $< && godep go test | |
lint: $(TARGETS_LINT) | |
# @$(GO_LINT) . | |
$(TARGETS_LINT): lint-%: % | |
@$(GO_LINT) $< | |
vet: $(TARGETS_VET) | |
# @$(GO_VET) ./*.go | |
$(TARGETS_VET): vet-%: % | |
@$(GO_VET) $</*.go |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment