When installing in a brand new environment, it will rely on the go command.
The code is from .gvm/scripts/install, and when the script executes the compile_go method, it requires that the go command has already been installed in the system.
If you use this script on a system where no version of go has been installed, it will not be able to run.
compile_go() {
display_message " * Compiling..."
# Test for Windows
case "$(uname)" in
*MINGW* | *WIN32* | *CYGWIN*)
MAKE_SCRIPT=make.bat
;;
*)
MAKE_SCRIPT=make.bash
;;
esac
[ -z "$GOROOT_BOOTSTRAP" ] && export GOROOT_BOOTSTRAP=$(go env GOROOT) 《-- this line
unset GOARCH && unset GOOS && unset GOPATH && unset GOBIN && unset GOROOT &&
export GOBIN=$GO_INSTALL_ROOT/bin &&
export PATH=$GOBIN:$PATH &&
export GOROOT=$GO_INSTALL_ROOT &&
if [ ! -f "$GO_INSTALL_ROOT/VERSION" ]; then echo "$GO_NAME" > "$GO_INSTALL_ROOT/VERSION"; fi &&
#builtin cd $GO_INSTALL_ROOT/src && ./all.bash &> $GVM_ROOT/logs/go-$GO_NAME-compile.log ||
builtin cd "$GO_INSTALL_ROOT/src" && chmod -f +x $MAKE_SCRIPT && ./$MAKE_SCRIPT &> "$GVM_ROOT/logs/go-$GO_NAME-compile.log" ||
(rm -rf "$GO_INSTALL_ROOT" && display_fatal "Failed to compile. Check the logs at $GVM_ROOT/logs/go-$GO_NAME-compile.log")
}
It's recommended to check if the go command exists in the environment before installation, and only then use the go env GOROOT command to initialize the GOROOT_BOOTSTRAP variable.
When installing in a brand new environment, it will rely on the
go
command.The code is from .gvm/scripts/install, and when the script executes the compile_go method, it requires that the go command has already been installed in the system.
If you use this script on a system where no version of
go
has been installed, it will not be able to run.It's recommended to check if the
go
command exists in the environment before installation, and only then use thego env GOROOT
command to initialize theGOROOT_BOOTSTRAP
variable.