bugfix version handling regression
[webi-installers/.git] / golang / install.bash
index d31304466886c8159807e9bf1f1d6a10a1d2f97a..ac60033db7b4a340eaeb3ed8839c56e6ad163c46 100644 (file)
@@ -57,22 +57,26 @@ update_go_home() {
     webi_path_add "$common_go_bin/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)"
 set -e
+cur_go_version=""
 if [ -n "$cur_go" ]; then
-  cur_ver=$(go version | cut -d' ' -f3 | sed 's:go::')
-  if [ "$cur_ver" == "$(echo $WEBI_VERSION | sed 's:\.0::g')" ]; then
-    echo "go v$WEBI_VERSION already installed at $cur_go"
+  cur_go_version=$(go version | cut -d' ' -f3 | sed 's:go::')
+
+  if [ "$cur_go_version" == "$(echo $WEBI_VERSION | sed 's:\.0::g')" ]; then
+    echo "go$WEBI_VERSION already installed at $cur_go"
     exit 0
-  elif [ "$cur_go" != "$new_go" ]; then
-    echo "WARN: possible conflict with go v$WEBI_VERSION at $cur_go"
+  else
+    if [ "$cur_go" != "$common_go_home/bin/go" ]; then
+      echo "WARN: possible conflict between go${WEBI_VERSION} and go${cur_go_version} at ${cur_go}"
+    fi
+    if [ -x "$new_go" ]; then
+      update_go_home
+      echo "switched to go${WEBI_VERSION} at $new_go_home"
+      exit 0
+    fi
   fi
 fi