Created
January 15, 2020 05:50
-
-
Save tebeka/fe81ed8145d003535e66919ae598012b to your computer and use it in GitHub Desktop.
Update go version
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| case $1 in | |
| -h | --help ) echo "usage: $(basename $0) VERSION"; exit;; | |
| esac | |
| if [ $# -ne 1 ]; then | |
| 1>&2 echo "error: wrong number of arguments" | |
| exit 1 | |
| fi | |
| cur=$(go version | awk '{print substr($3, 3)}') | |
| version=$1 | |
| echo "updating go to version ${version} (current: ${cur})" | |
| base=go${version}.linux-amd64.tar.gz | |
| url=https://dl.google.com/go/${base} | |
| file=${HOME}/Downloads/${base} | |
| dest=/opt/go${version} | |
| set -e | |
| set -x | |
| echo downloading ${url} | |
| curl -o ${file} ${url} | |
| echo unpacking | |
| rm -fr /tmp/go | |
| tar xz -C /tmp -f ${file} | |
| echo copy and symlink | |
| sudo mv /tmp/go ${dest} | |
| sudo ln -sfn ${dest} /opt/go |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment