@@ 33,13 33,22 @@ install_version() {
MINOR=$1
PATCH=$2
LIB_DIR=$(version_dir "$MINOR" "$PATCH")
+ FILENAME=go1.$MINOR.$PATCH.$GOOS-$GOARCH.tar.gz
+ DL_PATH=$LIB_DIR/../$FILENAME
mkdir -p "$LIB_DIR"
- if ! curl -L "https://golang.org/dl/go1.$MINOR.$PATCH.$GOOS-$GOARCH.tar.gz"\
- | tar --strip-components=1 -xzC "$LIB_DIR"; then
+ if ! curl -L -o "$DL_PATH" "https://golang.org/dl/$FILENAME"; then
echo "Couldn't download Go 1.$MINOR.$PATCH. Are you sure it exists?"
+ rm "$DL_PATH"
rm -rf "$LIB_DIR"
return 1
fi
+ if ! tar --strip-components=1 -xzC "$LIB_DIR" -f "$DL_PATH"; then
+ echo "Couldn't download Go 1.$MINOR.$PATCH. Are you sure it exists?"
+ rm "$DL_PATH"
+ rm -rf "$LIB_DIR"
+ return 1
+ fi
+ rm "$DL_PATH"
}
# activate_version symlinks a particular version of go to be the active