Skip to content

Commit

Permalink
fix(Makefile): Require go version 1.11
Browse files Browse the repository at this point in the history
  • Loading branch information
dustmop committed May 30, 2019
1 parent b37d186 commit 0cc2f9b
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
zip -r qri_darwin_386.zip qri_darwin_386 && rm -r qri_darwin_386

0 comments on commit 0cc2f9b

Please sign in to comment.