2021-12-22 13:51:22 +00:00
|
|
|
#!/bin/bash
|
2023-08-29 15:00:36 +00:00
|
|
|
##makedesc: Install golang v1.21.0
|
2023-04-14 04:06:40 +00:00
|
|
|
source `dirname $0`/../helpers || exit 255
|
2021-12-22 13:51:22 +00:00
|
|
|
|
2022-01-09 08:52:56 +00:00
|
|
|
# https://go.dev/dl/
|
2021-12-22 13:51:22 +00:00
|
|
|
# https://golang.org/doc/install
|
|
|
|
# https://www.vultr.com/docs/install-the-latest-version-of-golang-on-ubuntu
|
|
|
|
|
2023-08-29 15:00:36 +00:00
|
|
|
[ $1 ] && VERSION="$1" || VERSION="1.21.0"
|
2023-04-14 04:06:40 +00:00
|
|
|
title "Installing golang v$VERSION..."
|
2021-12-22 13:51:22 +00:00
|
|
|
|
2022-04-14 13:44:06 +00:00
|
|
|
FILE="go$VERSION.linux-amd64.tar.gz"
|
|
|
|
sudo rm -rf /usr/local/go && \
|
2023-04-14 04:06:40 +00:00
|
|
|
download "https://golang.org/dl/$FILE" "/tmp/$FILE" && \
|
|
|
|
sudo tar -xzf "/tmp/$FILE" -C /usr/local && \
|
|
|
|
rm -rf "/tmp/$FILE" && \
|
2022-04-14 13:44:06 +00:00
|
|
|
sudo chown $USER: -R /usr/local/go && \
|
2023-08-29 15:00:36 +00:00
|
|
|
echo 'export PATH="/usr/local/go/bin:$PATH"' >> "$HOME/.profile" && \
|
|
|
|
echo "export GOPATH=\"\$HOME/.go\"" >> "$HOME/.profile" && \
|
2023-04-14 04:06:40 +00:00
|
|
|
source ~/.profile
|
2023-04-11 15:43:14 +00:00
|
|
|
|
2023-04-14 04:06:40 +00:00
|
|
|
[ $? = 0 ] && {
|
|
|
|
echo
|
|
|
|
success "golang installed!"
|
|
|
|
info "NOTE: now run 'source ~/.profile' to apply new env vars"
|
2023-08-29 15:00:36 +00:00
|
|
|
go version
|
2023-04-14 04:06:40 +00:00
|
|
|
echo
|
|
|
|
}
|