From ad18295955388456ce750c0803d5160d35756bed Mon Sep 17 00:00:00 2001 From: Lars Gierth Date: Sat, 10 Feb 2018 03:46:43 +0100 Subject: [PATCH 1/3] build: match Go's GOPATH defaults behaviour License: MIT Signed-off-by: Lars Gierth --- bin/check_go_path | 5 +---- mk/golang.mk | 3 +++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/check_go_path b/bin/check_go_path index 229887043..8367c1601 100755 --- a/bin/check_go_path +++ b/bin/check_go_path @@ -7,10 +7,7 @@ if [ -z "$PWD" ]; then exit 1 fi -if [ -z "$GOPATH" ]; then - echo "GOPATH not set, you must have go configured properly to install ipfs" - exit 1 -fi +[ -z "$GOPATH" ] && GOPATH="$HOME/go" while [ ${#} -gt 1 ]; do if [ "$PWD" = "$2" ]; then diff --git a/mk/golang.mk b/mk/golang.mk index ebd8e19e0..8a7678377 100644 --- a/mk/golang.mk +++ b/mk/golang.mk @@ -1,6 +1,9 @@ # golang utilities GO_MIN_VERSION = 1.9 +# match Go's default GOPATH behaviour +GOPATH ?= $(HOME)/go + # pre-definitions GOCC ?= go GOTAGS ?= From 8c9725d88e5546a5de21ba4c7f230e10715bb07a Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Fri, 9 Mar 2018 10:32:19 +0100 Subject: [PATCH 2/3] Simplify GOPATH check License: MIT Signed-off-by: Jakub Sztandera --- bin/check_go_path | 2 -- mk/golang.mk | 5 +++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/bin/check_go_path b/bin/check_go_path index 8367c1601..0a9a27231 100755 --- a/bin/check_go_path +++ b/bin/check_go_path @@ -7,8 +7,6 @@ if [ -z "$PWD" ]; then exit 1 fi -[ -z "$GOPATH" ] && GOPATH="$HOME/go" - while [ ${#} -gt 1 ]; do if [ "$PWD" = "$2" ]; then exit 0 diff --git a/mk/golang.mk b/mk/golang.mk index 8a7678377..26b1b2eb5 100644 --- a/mk/golang.mk +++ b/mk/golang.mk @@ -1,8 +1,6 @@ # golang utilities GO_MIN_VERSION = 1.9 -# match Go's default GOPATH behaviour -GOPATH ?= $(HOME)/go # pre-definitions GOCC ?= go @@ -10,6 +8,9 @@ GOTAGS ?= GOFLAGS ?= GOTFLAGS ?= +# match Go's default GOPATH behaviour +export GOPATH ?= $(shell $(GOCC) env GOPATH) + DEPS_GO := TEST_GO := TEST_GO_BUILD := From 67a6e63eb29424ff18c6ebbef8175f327cde5696 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Fri, 9 Mar 2018 16:23:52 +0100 Subject: [PATCH 3/3] Correct output License: MIT Signed-off-by: Jakub Sztandera --- bin/check_go_path | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/check_go_path b/bin/check_go_path index 0a9a27231..589696466 100755 --- a/bin/check_go_path +++ b/bin/check_go_path @@ -15,5 +15,5 @@ while [ ${#} -gt 1 ]; do done echo "go-ipfs must be built from within your \$GOPATH directory." -echo "expected within '$GOPATH' but got '$PWD'" +echo "expected within '$(go env GOPATH)' but got '$PWD'" exit 1