Last active
July 10, 2024 01:11
-
-
Save codenoid/4806365032bb4ed62f381d8a76ddb8e6 to your computer and use it in GitHub Desktop.
This file contains 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
# codenoid | |
# https://gist.github.com/codenoid/4806365032bb4ed62f381d8a76ddb8e6 | |
printf "Checking latest Go version...\n"; | |
LATEST_GO_VERSION="$(curl --silent https://go.dev/VERSION?m=text | head -n 1)"; | |
LATEST_GO_DOWNLOAD_URL="https://go.dev/dl/${LATEST_GO_VERSION}.linux-amd64.tar.gz" | |
printf "cd to home ($USER) directory \n" | |
cd $HOME | |
printf "Downloading ${LATEST_GO_DOWNLOAD_URL}\n\n"; | |
curl -OJ -L --progress-bar $LATEST_GO_DOWNLOAD_URL | |
printf "Extracting file...\n" | |
tar -xf ${LATEST_GO_VERSION}.linux-amd64.tar.gz | |
export GOROOT="$HOME/go" | |
export GOPATH="$HOME/go/packages" | |
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin | |
printf '⚠️ ADD (OR REPLACE) THIS LINE BELOW TO YOUR ~/.bashrc ⚠️ | |
export GOROOT="$HOME/go" | |
export GOPATH="$HOME/go/packages" | |
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin | |
\n' | |
printf "You are ready to Go!"; | |
go version |
ok bro
Multiple Problems:
-
link moved:
https://golang.org
tohttps://go.dev
-
https://go.dev/VERSION?m=text
gives out a timestamp after the version, which causes the script to break.
Downloading https://golang.org/dl/go1.21.0
time 2023-08-04T20:14:06Z.linux-amd64.tar.gz
try to use something like curl --silent https://go.dev/VERSION?m=text | head -n 1
Sorry guys, I just update the main repository
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
better use
$HOME
instead/home/$USER