From 0cc2f9b13f0ec6d9f9e3daff3108fc6668302b2b Mon Sep 17 00:00:00 2001 From: Dustin Long Date: Thu, 30 May 2019 14:49:03 -0400 Subject: [PATCH] fix(Makefile): Require go version 1.11 --- Makefile | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 29a3e7187..946d64623 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,23 @@ ifndef GOPATH $(error $$GOPATH must be set. plz check: https://github.com/golang/go/wiki/SettingGOPATH) endif -build: require-gopath +require-goversion: + $(eval minver := go1.11) +# Get the version of the current go binary + $(eval havever := $(shell go version | awk '{print $$3}')) +# Magic happens. Sort using "." as the tab, keyed by groups of numbers, +# take the smallest. + $(eval match := $(shell echo "$(minver)\n$(havever)" | sort -t '.' -k 1,1 -k 2,2 -g -r | head -n 1)) +# If the minimum version either matches exactly what we have, or does not match +# the result of the magic sort above, we're okay. Otherwise, our binary's +# version isn't good enough: error. + @if [ "$(havever)" != "$(minver)" ]; then \ + if [ "$(match)" == "$(minver)" ]; then \ + echo "Error: invalid go version $(havever), need $(minver)"; exit 1; \ + fi; \ + fi; + +build: require-gopath require-goversion @echo "\n1/5 install non-gx deps:\n" go get -v -u $(GOPACKAGES) @echo "\n2/5 install gx:\n" @@ -126,4 +142,4 @@ build-cross-platform: @echo "building qri_darwin_386" mkdir qri_darwin_386 env GOOS=darwin GOARCH=386 go build -o qri_darwin_386/qri . - zip -r qri_darwin_386.zip qri_darwin_386 && rm -r qri_darwin_386 \ No newline at end of file + zip -r qri_darwin_386.zip qri_darwin_386 && rm -r qri_darwin_386