Корректировка golang

This commit is contained in:
Anthony Axenov 2022-01-09 16:52:56 +08:00
parent d025934894
commit 551f80ef29
Signed by: anthony
GPG Key ID: EA9EC32FF7CCD4EC

View File

@ -1,27 +1,28 @@
#!/bin/bash #!/bin/bash
. "../src/01-common.sh" || exit 5 echo
title "Installing golang" echo "==============================================="
echo "Installing golang..."
echo "==============================================="
echo
# https://go.dev/dl/
# https://golang.org/doc/install # https://golang.org/doc/install
# https://www.vultr.com/docs/install-the-latest-version-of-golang-on-ubuntu # https://www.vultr.com/docs/install-the-latest-version-of-golang-on-ubuntu
# if [ "$EUID" -ne 0 ] [ $1 ] && VERSION="$1" || VERSION="1.17.6"
# then echo "*** root permissions required ***"
# exit
# fi
[ $1 ] && VERSION="$1" || VERSION="1.17.5"
FILE="go$VERSION.linux-amd64.tar.gz" FILE="go$VERSION.linux-amd64.tar.gz"
sudo rm -rf /usr/local/go sudo rm -rf /usr/local/go
wget "https://golang.org/dl/$FILE" -O /tmp/$FILE wget "https://golang.org/dl/$FILE" -O /tmp/$FILE
sudo tar -xzf $FILE -C /usr/local sudo tar -xzf $FILE -C /usr/local
rm -rf /tmp/$FILE rm -rf /tmp/$FILE
sudo chown $USER: -R /usr/local/go sudo chown anthony: -R /usr/local/go
echo "export PATH=$PATH:/usr/local/go/bin" >> /home/anthony/.profile echo "export PATH=$PATH:/usr/local/go/bin" >> /home/anthony/.profile
echo "export GOPATH=~/.go" >> /home/anthony/.profile echo "export GOPATH=~/.go" >> /home/anthony/.profile
# source ~/.profile # source ~/.profile
success "$(go version)" echo
info "NOTE: now run \`source ~/.profile\` to apply new env vars" go version
echo "NOTE: now run 'source ~/.profile' to apply new env vars"
echo