forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request cockroachdb#21426 from benesch/go-min-vers
build: only require a minimum version of Go
- Loading branch information
Showing
3 changed files
with
43 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Detect whether the installed version of Go can build this version of | ||
# CockroachDB. | ||
# | ||
# To bump the required version of Go, edit the last conditional appropriately. | ||
# | ||
# Note: this script is invoked by Make, so it has odd error reporting semantics. | ||
# Errors are printed to stdout; the Go version is compatible iff nothing is | ||
# printed to stdout. The exit code is meaningless. | ||
|
||
# Ensure stray error messages are printed to stdout, or they'll go unnoticed by | ||
# Make. | ||
exec 2>&1 | ||
|
||
go=${1-go} | ||
|
||
if ! raw_version=$("$go" version 2>&1); then | ||
echo "unable to detect go version: $raw_version" | ||
exit | ||
fi | ||
|
||
if ! version=$(grep -oE "[0-9]+\.[0-9]+" <<< "$raw_version"); then | ||
echo "unable to parse go version '$raw_version'" | ||
exit | ||
fi | ||
|
||
version_major=$(cut -f1 -d. <<< "$version") | ||
version_minor=$(cut -f2 -d. <<< "$version") | ||
if (( version_major != 1 )) || (( version_minor < 9 )); then | ||
echo "go1.9+ required (detected go$version)" | ||
exit | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters