You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.5 KiB
Bash
45 lines
1.5 KiB
Bash
#!/usr/bin/env bash
|
|
function gvm_pkgset_use() {
|
|
[[ "$1" != "" ]] ||
|
|
display_error "Please specify a package set" || return 1
|
|
|
|
[[ "$gvm_go_name" != "" ]] ||
|
|
display_error "No Go version selected" || return 1
|
|
|
|
if [[ "$1" == "--local" ]]; then
|
|
. "$GVM_ROOT/scripts/function/find_local_pkgset"
|
|
local LOCAL_TOP=$(find_local_pkgset)
|
|
unset -f find_local_pkgset
|
|
[[ -d $LOCAL_TOP ]] ||
|
|
display_error "Cannot find local package set" || return 1
|
|
LOCAL_TOP=$LOCAL_TOP/.gvm_local
|
|
|
|
fuzzy_match=$($LS_PATH "$LOCAL_TOP/environments" | $SORT_PATH | $GREP_PATH "$gvm_go_name@" | $GREP_PATH "local" | $HEAD_PATH -n 1) ||
|
|
display_error "Cannot find local package set" || return 1
|
|
|
|
[[ "$2" != "--default" ]] ||
|
|
display_error "Cannot set local pkgset as default" || return 1
|
|
|
|
gvm_export_path
|
|
. "$LOCAL_TOP/environments/$fuzzy_match" ||
|
|
display_error "Failed to source the package set environment" || return 1
|
|
|
|
echo "Now using version $gvm_go_name in local package set"
|
|
echo "Local GOPATH is now $LOCAL_TOP"
|
|
else
|
|
fuzzy_match=$($LS_PATH "$GVM_ROOT/environments" | $SORT_PATH | $GREP_PATH "$gvm_go_name@" | $GREP_PATH "$1" | $HEAD_PATH -n 1) ||
|
|
display_error "Invalid package set" || return 1
|
|
|
|
gvm_export_path
|
|
. "$GVM_ROOT/environments/$fuzzy_match" ||
|
|
display_error "Failed to source the package set environment" || return 1
|
|
|
|
if [[ "$2" == "--default" ]]; then
|
|
cp "$GVM_ROOT/environments/$fuzzy_match" "$GVM_ROOT/environments/default"
|
|
fi
|
|
|
|
echo "Now using version $fuzzy_match"
|
|
fi
|
|
}
|
|
|