bugfix / switch installed versions
[webi-installers/.git] / golang / install.bash
index caeea6e504ce237f53a4c19850fede71ffa2f758..a6a8592ca6d76febbd7c59d5fd44268d99b9cc1f 100644 (file)
@@ -41,9 +41,24 @@ set -u
 # Install go #
 ###################
 
+common_go_home="${HOME}/.local/opt/go-v${WEBI_VERSION}"
 new_go_home="${HOME}/.local/opt/go-v${WEBI_VERSION}"
 new_go="${HOME}/.local/opt/go-v${WEBI_VERSION}/bin/go"
 
+update_go_home() {
+    rm -rf "$common_go_home"
+    ln -s "$new_go_home" "$common_go_home"
+
+    # TODO get better output from pathman / output the path to add as return to webi bootstrap
+    webi_path_add "$common_go_home/bin"
+    webi_path_add "$HOME/go/bin"
+}
+
+if [ -x "$new_go_home/bin/go" ]; then
+  update_go_home
+  exit 0
+fi
+
 # Test for existing version
 set +e
 cur_go="$(command -v go)"
@@ -96,9 +111,7 @@ popd 2>&1 >/dev/null
 #   Update PATH   #
 ###################
 
-# TODO get better output from pathman / output the path to add as return to webi bootstrap
-webi_path_add "$new_go_home/bin"
-webi_path_add "$HOME/go/bin"
+update_go_home
 
 echo "Installed 'go' (and go tools)"
 echo ""