Skip to content

Instantly share code, notes, and snippets.

@tebeka
Created July 13, 2022 05:55
Show Gist options
  • Save tebeka/a88052bd0fad07d42396d49c7fe6c1cd to your computer and use it in GitHub Desktop.
Save tebeka/a88052bd0fad07d42396d49c7fe6c1cd to your computer and use it in GitHub Desktop.
#!/bin/bash
case $1 in
-h | --help ) echo "usage: $(basename $0) [VERSION]"; exit;;
esac
if [ $# -gt 1 ]; then
1>&2 echo "error: wrong number of argument"
exit 1
fi
cur=$(go version | awk '{print substr($3, 3)}')
if [ -z "$1" ]; then
# bump patch
version=$(echo ${cur} | awk -F. '{print $1 "." $2 "." $3+1}')
else
version=$1
fi
echo "updating go to version ${version} (current: ${cur})"
go install golang.org/dl/go${version}@latest
go${version} download
echo "updating link"
ln -sfn ${HOME}/sdk/go${version} ${HOME}/sdk/go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment