mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 10:27:46 +08:00
The usage of a native 'go' command has been replaced with a make & environment variable $GOCC. This enables building with multiple go versions on a single machine as documented: * https://golang.org/doc/install#extra_versions This enables the usage of: ```bash $ make install $ # OR $ GOCC=go1.12.3 make install $ # OR $ GOCC=go1.12.4 make install ``` And the build and test tools now pick up on this change On branch go-version-check Changes to be committed: modified: Rules.mk modified: bin/check_go_version modified: bin/dist_get modified: bin/maketarball.sh modified: coverage/Rules.mk modified: mk/golang.mk modified: mk/tarball.mk License: MIT Signed-off-by: Chris Buesser <christopher.buesser@gmail.com>
45 lines
1.1 KiB
Bash
Executable File
45 lines
1.1 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# Check that the go version is at least equal to a minimum version
|
|
# number.
|
|
#
|
|
# Call it for example like this:
|
|
#
|
|
# $ check_go_version "1.5.2"
|
|
#
|
|
|
|
USAGE="$0 GO_MIN_VERSION"
|
|
|
|
die() {
|
|
printf >&2 "fatal: %s\n" "$@"
|
|
exit 1
|
|
}
|
|
|
|
# Get arguments
|
|
|
|
test "$#" -eq "1" || die "This program must be passed exactly 1 arguments" "Usage: $USAGE"
|
|
|
|
GO_MIN_VERSION="$1"
|
|
|
|
UPGRADE_MSG="Please take a look at https://golang.org/doc/install to install or upgrade go."
|
|
|
|
# Get path to the directory containing this file
|
|
# If $0 has no slashes, uses "./"
|
|
PREFIX=$(expr "$0" : "\(.*\/\)") || PREFIX='./'
|
|
# Include the 'check_at_least_version' function
|
|
. ${PREFIX}check_version
|
|
|
|
# Check that the go binary exist and is in the path
|
|
|
|
GOCC=${GOCC="go"}
|
|
|
|
type ${GOCC} >/dev/null 2>&1 || die_upgrade "go is not installed or not in the PATH!"
|
|
|
|
# Check the go binary version
|
|
|
|
VERS_STR=$(${GOCC} version 2>&1) || die "'go version' failed with output: $VERS_STR"
|
|
|
|
GO_CUR_VERSION=$(expr "$VERS_STR" : ".*go version go\([^ ]*\) .*") || die "Invalid 'go version' output: $VERS_STR"
|
|
|
|
check_at_least_version "$GO_MIN_VERSION" "$GO_CUR_VERSION" "${GOCC}"
|