~whereswaldon/gover

3582c920d62ad8f8e6bd07d38389f01ac137726e — Chris Waldon 4 years ago 6ff3747
fix: properly handle patch version being zero
1 files changed, 8 insertions(+), 1 deletions(-)

M gover
M gover => gover +8 -1
@@ 16,6 16,10 @@ GOARCH=amd64 # TODO: find a portable way to determine this without go installed
# version_dir emits the directory into which a particular go
# version should be installed
version_dir() {
    if [ "$2" = "0" ]; then
        echo "$PREFIX/lib/go-1.$1"
        return 0
    fi
    echo "$PREFIX/lib/go-1.$1.$2"
}



@@ 34,6 38,9 @@ install_version() {
    PATCH=$2
    LIB_DIR=$(version_dir "$MINOR" "$PATCH")
    FILENAME=go1.$MINOR.$PATCH.$GOOS-$GOARCH.tar.gz
    if [ "$PATCH" = "0" ]; then
    FILENAME=go1.$MINOR.$GOOS-$GOARCH.tar.gz
    fi
    DL_PATH=$LIB_DIR/../$FILENAME
    mkdir -p "$LIB_DIR"
    if ! curl -L -o "$DL_PATH" "https://golang.org/dl/$FILENAME"; then


@@ 56,7 63,7 @@ install_version() {
activate_version() {
    MINOR=$1
    PATCH=$2
    ln -svf "../lib/go-1.$MINOR.$PATCH/bin/go" "$PREFIX/bin/go"
    ln -svnf "$(version_dir "$1" "$2")/bin/go" "$PREFIX/bin/go"
}

gover() {