vitess-gh/tools/shell_functions.inc

20 строки
691 B
PHP

# Copyright 2015, Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can
# be found in the LICENSE file.
# Library of functions which are used by bootstrap.sh or the Makefile.
# goversion_min returns true if major.minor go version is at least some value.
function goversion_min() {
[[ "$(go version)" =~ go([0-9]+)\.([0-9]+) ]]
gotmajor=${BASH_REMATCH[1]}
gotminor=${BASH_REMATCH[2]}
[[ "$1" =~ ([0-9]+)\.([0-9]+) ]]
wantmajor=${BASH_REMATCH[1]}
wantminor=${BASH_REMATCH[2]}
[ "$gotmajor" -lt "$wantmajor" ] && return 1
[ "$gotmajor" -gt "$wantmajor" ] && return 0
[ "$gotminor" -lt "$wantminor" ] && return 1
return 0
}