Skip to content

Instantly share code, notes, and snippets.

@codenoid
Last active August 21, 2023 07:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codenoid/4806365032bb4ed62f381d8a76ddb8e6 to your computer and use it in GitHub Desktop.
Save codenoid/4806365032bb4ed62f381d8a76ddb8e6 to your computer and use it in GitHub Desktop.
# 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
@gczobel-f5
Copy link

better use $HOME instead /home/$USER

@codenoid
Copy link
Author

codenoid commented Jul 9, 2023

ok bro

@cethien
Copy link

cethien commented Aug 13, 2023

Multiple Problems:

  1. link moved: https://golang.org to https://go.dev

  2. 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

@codenoid
Copy link
Author

Sorry guys, I just update the main repository

https://github.com/codenoid/install-latest-go-linux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment