From 0f86740a7fdca6963a0f2e4a0bd3b563c644b50a Mon Sep 17 00:00:00 2001 From: Chris Cummer Date: Sun, 13 Jan 2019 11:56:54 -0800 Subject: [PATCH] Set the GOPATH if not set when using the Makefile --- Makefile | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index cdafaaac..b9096b3f 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,23 @@ .PHONY: contrib_check dependencies install run size +# detect GOPATH if not set +ifndef $(GOPATH) + $(info GOPATH is not set, autodetecting..) + TESTPATH := $(dir $(abspath ../../..)) + DIRS := bin pkg src + # create a ; separated line of tests and pass it to shell + MISSING_DIRS := $(shell $(foreach entry,$(DIRS),test -d "$(TESTPATH)$(entry)" || echo "$(entry)";)) + ifeq ($(MISSING_DIRS),) + $(info Found GOPATH: $(TESTPATH)) + export GOPATH := $(TESTPATH) + else + $(info ..missing dirs "$(MISSING_DIRS)" in "$(TESTDIR)") + $(info GOPATH autodetection failed) + endif +endif + build: - go build -race -o bin/wtf + go build -o bin/wtf contrib_check: npx all-contributors-cli check