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 fi
recipe 'git' recipe 'git'
recipe 'vim-settings' recipe 'vim-settings'
recipe 'golang' if ! is_installed 'golang'; then
recipe 'golang'
set_installed 'golang'
fi
recipe 'fish' recipe 'fish'
if $install_ui_terms ; then if $install_ui_terms ; then
recipe 'alacritty' recipe 'alacritty'

View File

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