2013-08-07 20:23:13 -07:00
|
|
|
#!/bin/bash
|
|
|
|
|
2019-11-12 17:59:41 -08:00
|
|
|
# Installs golang from the web
|
2013-08-07 20:23:13 -07:00
|
|
|
|
2021-12-02 17:06:33 -08:00
|
|
|
ARCH=$(uname -m)
|
2022-04-05 16:54:47 -07:00
|
|
|
if [ "$ARCH" = "x86_64" ]; then
|
|
|
|
ARCH=amd64
|
|
|
|
fi
|
|
|
|
|
2023-03-08 14:58:55 -08:00
|
|
|
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
|