-
-
Save lordnynex/d55844c890532baa4d7434109ead051a to your computer and use it in GitHub Desktop.
Makefile for Golang project that has multiple packages
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
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