This is my super simple script to upgrade to a newer Go version. You might find it handy as well.



function latestGo {
    local LATEST=$(curl -s '' | jq -r '.[0].version')
    local INSTALLED=$(go version | awk '{ print $3 }')
    if [[ ${INSTALLED} == ${LATEST} ]]; then
        echo Go is up to date, running ${LATEST} >&2
        exit 0
    echo Upgrading Go from ${INSTALLED} to ${LATEST} >&2
    local GOLANG=${LATEST}.linux-amd64.tar.gz
    local TAR=$(basename $GOLANG)

    ( cd ${GODIR}
      echo Downloading and extracting: $GOLANG >&2
      wget -q $GOLANG && rm -rf go && tar xvfz ${TAR}