futuretea

脚本如下:

#!/usr/bin/env bash
[[ -n $DEBUG ]] && set -x
set -eou pipefail

useage(){
  cat <<"EOF"
USAGE:
    gov.sh VERSION
EOF
}

if [ $# -lt 1 ];then
    useage
    exit
fi

VERSION=$1
if [ -z "${GOROOT}" ];then
  GOROOT="/usr/local/bin/go"
fi
sudo rm -f "${GOROOT}"
GOPACK="${GOROOT}${VERSION}"
if [ ! -d "${GOPACK}" ];then
  sudo wget "https://dl.google.com/go/go${VERSION}.linux-amd64.tar.gz" -cP "${HOME}/Downloads/"
  TEMPDIR=$(mktemp -d)
  tar -zxf "${HOME}/Downloads/go${VERSION}.linux-amd64.tar.gz" -C "${TEMPDIR}"
  mkdir -p "${TEMPDIR}"
  sudo mv "${TEMPDIR}/go" "${GOPACK}"
  sudo rm -r "${TEMPDIR}"
fi
sudo ln -s "${GOPACK}" "${GOROOT}"
GOVERSIONNOW="$(go version | awk \'{print $3}\' | sed \'s/go//g\')"
echo "go ${GOVERSIONNOW}"

使用方式:

本机没有的版本会自动下载安装

gov 1.13.5

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-07-13
  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
  • 2021-05-23
  • 2022-01-16
  • 2021-05-30
猜你喜欢
  • 2021-07-07
  • 2022-12-23
  • 2021-10-25
  • 2021-12-16
  • 2021-12-25
  • 2021-07-25
  • 2022-12-23
相关资源
相似解决方案