Last active
August 29, 2015 14:17
-
-
Save 13k/964039295699086c4593 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Based on chruby's auto feature | |
# https://github.com/postmodern/chruby/blob/bfd78880fbbbf13635e1f97f83225c6a03ca6e89/share/chruby/auto.sh | |
function gvm_auto() { | |
local dir="$PWD/" version | |
until [[ -z "$dir" ]]; do | |
dir="${dir%/*}" | |
if { read -r version <"$dir/.go-version"; } 2>/dev/null || [[ -n "$version" ]]; then | |
version="${version%%[[:space:]]}" | |
if [[ "$version" == "$GVM_AUTO_VERSION" ]]; then return | |
else | |
GVM_AUTO_VERSION="$version" | |
if echo "$version" | grep -q "@"; then | |
local name="${version%@*}" | |
local pkgset="${version#*@}" | |
gvm use "$name" > /dev/null && \ | |
gvm pkgset use "$pkgset" > /dev/null | |
else | |
gvm use "$version" > /dev/null | |
fi | |
return $? | |
fi | |
fi | |
done | |
if [[ -n "$GVM_AUTO_VERSION" ]]; then | |
unset GVM_AUTO_VERSION | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment