shoestrap/recipes/default/golang
2024-06-13 12:44:36 -07:00

27 lines
736 B
Bash
Executable File

#!/bin/bash
# Installs golang from the web
ARCH=$(uname -m)
if [ "$ARCH" = "x86_64" ]; then
ARCH=amd64
fi
function install_go() {
local version="1.22.4"
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