open-vault/scripts/goversioncheck.sh
Joel Thompson fb6cd052c5 Explicitly check go version in build (#3309)
* Explicitly check go version in build

Several GH issues have been opened by people trying to use an older
version of Go to build Vault (e.g., #3307 is the most recent). This adds
an explicit check to the build to hopefully make it more clear to users
in the future.

* Also add checking for go patch version

* Up minimum go version

And fix a comment

* Bump travis to go1.9.1
2017-10-19 16:30:19 -04:00

20 lines
672 B
Bash
Executable file

#!/usr/bin/env bash
GO_VERSION_MIN=$1
echo "==> Checking that build is using go version >= $1..."
GO_VERSION=$(go version | grep -o 'go[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?' | tr -d 'go')
IFS="." read -r -a GO_VERSION_ARR <<< "$GO_VERSION"
IFS="." read -r -a GO_VERSION_REQ <<< "$GO_VERSION_MIN"
if [[ ${GO_VERSION_ARR[0]} -lt ${GO_VERSION_REQ[0]} ||
( ${GO_VERSION_ARR[0]} -eq ${GO_VERSION_REQ[0]} &&
( ${GO_VERSION_ARR[1]} -lt ${GO_VERSION_REQ[1]} ||
( ${GO_VERSION_ARR[1]} -eq ${GO_VERSION_REQ[1]} && ${GO_VERSION_ARR[2]} -lt ${GO_VERSION_REQ[2]} )))
]]; then
echo "Vault requires go $GO_VERSION_MIN to build; found $GO_VERSION."
exit 1
fi