Avoid reinstall of golang

This commit is contained in:
ViViDboarder 2023-03-08 14:58:55 -08:00
parent cf5cdb8186
commit 17d8e71664
2 changed files with 21 additions and 9 deletions

View File

@ -75,7 +75,10 @@ if [ "$(uname)" == 'Darwin' ]; then
fi
recipe 'git'
recipe 'vim-settings'
recipe 'golang'
if ! is_installed 'golang'; then
recipe 'golang'
set_installed 'golang'
fi
recipe 'fish'
if $install_ui_terms ; then
recipe 'alacritty'

View File

@ -2,16 +2,25 @@
# Installs golang from the web
version="1.19"
ARCH=$(uname -m)
if [ "$ARCH" = "x86_64" ]; then
ARCH=amd64
fi
if [[ "$UNAME_STR" == "Darwin" ]]; then
wget -P "$TMP_DIR/" "https://go.dev/dl/go${version}.darwin-$ARCH.pkg"
sudo installer -target / -pkg "$TMP_DIR/go${version}.darwin-$ARCH.pkg"
elif [[ "$UNAME_STR" == "Linux" ]]; then
wget -P "$TMP_DIR/" "https://go.dev/dl/go${version}.linux-$ARCH.tar.gz"
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf "$TMP_DIR/go${version}.linux-$ARCH.tar.gz"
fi
function install_go() {
local version="1.20.2"
if command -v "go" > /dev/null 2>&1 && go version | grep "$version"; then
echo "Go version $version is already installed"
return 0
fi
if [[ "$UNAME_STR" == "Darwin" ]]; then
wget -P "$TMP_DIR/" "https://go.dev/dl/go${version}.darwin-$ARCH.pkg"
sudo installer -target / -pkg "$TMP_DIR/go${version}.darwin-$ARCH.pkg"
elif [[ "$UNAME_STR" == "Linux" ]]; then
wget -P "$TMP_DIR/" "https://go.dev/dl/go${version}.linux-$ARCH.tar.gz"
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf "$TMP_DIR/go${version}.linux-$ARCH.tar.gz"
fi
}
install_go