2017-10-19 20:30:19 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2020-01-09 17:35:32 +00:00
|
|
|
GO_CMD=${GO_CMD:-go}
|
|
|
|
|
2017-10-19 20:30:19 +00:00
|
|
|
GO_VERSION_MIN=$1
|
|
|
|
echo "==> Checking that build is using go version >= $1..."
|
|
|
|
|
2020-01-09 17:35:32 +00:00
|
|
|
if $GO_CMD version | grep -q devel;
|
2019-01-29 16:26:49 +00:00
|
|
|
then
|
|
|
|
GO_VERSION="devel"
|
|
|
|
else
|
2020-01-09 17:35:32 +00:00
|
|
|
GO_VERSION=$($GO_CMD version | grep -o 'go[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?' | tr -d 'go')
|
2017-10-19 20:30:19 +00:00
|
|
|
|
2019-01-29 16:26:49 +00:00
|
|
|
IFS="." read -r -a GO_VERSION_ARR <<< "$GO_VERSION"
|
|
|
|
IFS="." read -r -a GO_VERSION_REQ <<< "$GO_VERSION_MIN"
|
2017-10-19 20:30:19 +00:00
|
|
|
|
2019-01-29 16:26:49 +00:00
|
|
|
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
|
2017-10-19 20:30:19 +00:00
|
|
|
fi
|
2018-09-18 21:28:37 +00:00
|
|
|
|
2019-01-29 16:26:49 +00:00
|
|
|
echo "==> Using go version $GO_VERSION..."
|