mostly update comments, fix gitea releases.js
[webi-installers/.git] / golang / install.bash
index 422b0ebf4b1d70c0c4a8f074c5effbc6feeda7ff..fead4b6b5cc7d938aabe96ac5726bb984f5a7e01 100644 (file)
@@ -53,7 +53,13 @@ pkg_get_current_version() {
     #       go version go1.14.2 darwin/amd64
     # This trims it down to just the version number:
     #       1.14.2
-    echo "$(go version | cut -d' ' -f3 | sed 's:go::')"
+    echo "$(go version >2/dev/null | head -n 1 | cut -d' ' -f3 | sed 's:go::')"
+}
+
+pkg_format_cmd_version() {
+    # 'go v1.14.0' will be 'go1.14'
+    my_version=$(echo "$1" | sed 's:\.0::g')
+    echo "${pkg_cmd_name}${my_version}"
 }
 
 pkg_link_new_version() {
@@ -67,7 +73,7 @@ pkg_link_new_version() {
     # 'GOBIN' is set above to "${HOME}/go"
     # 'GOBIN_REAL' will be "${HOME}/.local/opt/go-bin-v${WEBI_VERSION}"
     rm -rf "$GOBIN"
-    mkdir -p "$GOBIN_REAL"
+    mkdir -p "$GOBIN_REAL/bin"
     ln -s "$GOBIN_REAL" "$GOBIN"
 }
 
@@ -95,7 +101,7 @@ pkg_install() {
 
         # rename the entire extracted folder to the new location
         # (this will be "$HOME/.local/opt/go-v$WEBI_VERSION" by default)
-        mv ./go* "$pkg_new_opt"
+        mv ./"$pkg_cmd_name"* "$pkg_new_opt"
 
     popd 2>&1 >/dev/null
 }
@@ -107,9 +113,10 @@ pkg_post_install() {
     # Updates PATH with
     #       "$HOME/.local/opt/go"
     webi_path_add "$pkg_common_bin"
-    webi_path_add "$GOBIN"
+    webi_path_add "$GOBIN/bin"
 
     # Install x go
+    echo "Installing go extended tools (goimports, gorename, etc)"
     "$pkg_common_cmd" get golang.org/x/tools/cmd/goimports > /dev/null 2>/dev/null
     "$pkg_common_cmd" get golang.org/x/tools/cmd/gorename > /dev/null 2>/dev/null
     "$pkg_common_cmd" get golang.org/x/tools/cmd/gotype > /dev/null 2>/dev/null