From d15b4435c9a3d417b0fb8d343a7446ff37e45dd9 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Mon, 15 Nov 2021 11:06:58 +0000 Subject: [PATCH] bugfix(go): use go install for newer versions of go, cleanup --- golang/install.sh | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/golang/install.sh b/golang/install.sh index 01b5a19..4530dfa 100644 --- a/golang/install.sh +++ b/golang/install.sh @@ -1,3 +1,4 @@ +#!/bin/bash set -e set -u @@ -19,7 +20,10 @@ 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 2> /dev/null | head -n 1 | cut -d' ' -f3 | sed 's:go::')" + go version 2> /dev/null | + head -n 1 | + cut -d' ' -f3 | + sed 's:go::' } pkg_format_cmd_version() { @@ -58,46 +62,55 @@ pkg_post_install() { # See https://pkg.go.dev/mod/golang.org/x/tools?tab=packages + my_install="install" + # note: we intend a lexical comparison, so this is correct + #shellcheck disable=SC2072 + if [[ ${WEBI_VERSION} < "1.16" ]]; then + my_install="get" + fi + echo "" echo godoc - "$pkg_dst_cmd" get golang.org/x/tools/cmd/godoc@latest > /dev/null #2>/dev/null + "$pkg_dst_cmd" "${my_install}" golang.org/x/tools/cmd/godoc@latest > /dev/null #2>/dev/null echo "" echo gopls - "$pkg_dst_cmd" get golang.org/x/tools/gopls@latest > /dev/null #2>/dev/null + "$pkg_dst_cmd" "${my_install}" golang.org/x/tools/gopls@latest > /dev/null #2>/dev/null echo "" echo guru - "$pkg_dst_cmd" get golang.org/x/tools/cmd/guru@latest > /dev/null #2>/dev/null + "$pkg_dst_cmd" "${my_install}" golang.org/x/tools/cmd/guru@latest > /dev/null #2>/dev/null echo "" echo golint - "$pkg_dst_cmd" get golang.org/x/lint/golint@latest > /dev/null #2>/dev/null + "$pkg_dst_cmd" "${my_install}" golang.org/x/lint/golint@latest > /dev/null #2>/dev/null echo "" echo goimports - "$pkg_dst_cmd" get golang.org/x/tools/cmd/goimports@latest > /dev/null #2>/dev/null + "$pkg_dst_cmd" "${my_install}" golang.org/x/tools/cmd/goimports@latest > /dev/null #2>/dev/null echo "" echo gomvpkg - "$pkg_dst_cmd" get golang.org/x/tools/cmd/gomvpkg@latest > /dev/null #2>/dev/null + "$pkg_dst_cmd" "${my_install}" golang.org/x/tools/cmd/gomvpkg@latest > /dev/null #2>/dev/null echo "" echo gorename - "$pkg_dst_cmd" get golang.org/x/tools/cmd/gorename@latest > /dev/null #2>/dev/null + "$pkg_dst_cmd" "${my_install}" golang.org/x/tools/cmd/gorename@latest > /dev/null #2>/dev/null echo "" echo gotype - "$pkg_dst_cmd" get golang.org/x/tools/cmd/gotype@latest > /dev/null #2>/dev/null + "$pkg_dst_cmd" "${my_install}" golang.org/x/tools/cmd/gotype@latest > /dev/null #2>/dev/null echo "" echo stringer - "$pkg_dst_cmd" get golang.org/x/tools/cmd/stringer@latest > /dev/null #2>/dev/null + "$pkg_dst_cmd" "${my_install}" golang.org/x/tools/cmd/stringer@latest > /dev/null #2>/dev/null echo "" } pkg_done_message() { - echo "Installed 'go' v$WEBI_VERSION to ~/.local/opt/go" - echo "Installed go 'x' tools to GOBIN=\$HOME/go/bin" + echo "Installed 'go v$WEBI_VERSION' to ~/.local/opt/go" + # note: literal $HOME on purpose + #shellcheck disable=SC2016 + echo 'Installed go "x" tools to GOBIN=$HOME/go/bin' } -- 2.25.1