golang rework

This commit is contained in:
Anthony Axenov 2024-07-31 23:26:27 +08:00
parent e9638e845c
commit 6d7719d568
Signed by: anthony
GPG Key ID: EA9EC32FF7CCD4EC

View File

@ -1,30 +1,28 @@
#!/bin/bash #!/bin/bash
##makedesc: Install golang v1.18.3 ##makedesc: Install golang v1.21.0
source `dirname $0`/../helpers || exit 255
# https://go.dev/dl/ # 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
[ $1 ] && VERSION="$1" || VERSION="1.21.6"
title "Installing golang v$VERSION..."
[ $1 ] && VERSION="$1" || VERSION="1.18.3"
FILE="go$VERSION.linux-amd64.tar.gz" FILE="go$VERSION.linux-amd64.tar.gz"
echo
echo "==============================================="
echo "Installing golang v$VERSION..."
echo "==============================================="
echo
sudo rm -rf /usr/local/go && \ sudo rm -rf /usr/local/go && \
wget "https://golang.org/dl/$FILE" -O /tmp/$FILE && \ download "https://golang.org/dl/$FILE" "/tmp/$FILE" && \
sudo tar -xzf /tmp/$FILE -C /usr/local && \ sudo tar -xzf "/tmp/$FILE" -C /usr/local && \
rm -rf /tmp/$FILE && \ rm -rf "/tmp/$FILE" && \
sudo chown $USER: -R /usr/local/go && \ sudo chown $USER: -R /usr/local/go && \
echo 'export PATH="$PATH:/usr/local/go/bin\"' >> $HOME/.profile && \ echo 'export PATH="/usr/local/go/bin:$PATH"' >> "$HOME/.profile" && \
echo 'export GOPATH="$HOME/.go"' >> $HOME/.profile echo "export GOPATH=\"\$HOME/.go\"" >> "$HOME/.profile" && \
source ~/.profile
echo [ $? = 0 ] && {
echo "Finish!" echo
go version success "golang installed!"
echo "NOTE: now run 'source ~/.profile' to apply new env vars" info "NOTE: now run 'source ~/.profile' to apply new env vars"
echo go version
echo
}