Script to update go version

Although Go installation it’s a pretty straight-forward process, it can be done even easier if a script is used to install and update your golang installation.

We are going to use update-golang script.

$ go version

go version go1.17.6 linux/arm64

$ git clone

Clonando en 'update-golang'...
remote: Enumerating objects: 706, done.
remote: Counting objects: 100% (62/62), done.
remote: Compressing objects: 100% (45/45), done.
remote: Total 706 (delta 28), reused 39 (delta 17), pack-reused 644
Recibiendo objetos: 100% (706/706), 104.27 KiB | 1.30 MiB/s, listo.
Resolviendo deltas: 100% (363/363), listo.

$ sudo ./ version 0.25 find_latest: found last release: 1.18.2 user: uid=0(root) gid=0(root) grupos=0(root),4(adm),20(dialout),119(wireshark),145(kaboxer) RELEASE_LIST= SOURCE= DESTINATION=/usr/local RELEASE=1.18.2 OS=linux ARCH_PROBE=uname -m ARCH=arm64 PROFILED=/etc/profile.d/ CACHE=/usr/local GOPATH= DEBUG= will install golang go1.18.2.linux-arm64 as: /usr/local/go is remote
--2022-05-14 18:17:46--
Resolviendo (,,, ...
Conectando con ([]:443... conectado.
Petición HTTP enviada, esperando respuesta... 200 OK
Longitud: 108861264 (104M) [application/x-gzip]
Grabando a: «/usr/local/go1.18.2.linux-arm64.tar.gz»

/usr/local/go1.18.2.linux-arm64.tar.gz                      100%[========================================================================================================================================>] 103,82M  20,0MB/s    en 5,8s    

2022-05-14 18:17:52 (18,0 MB/s) - «/usr/local/go1.18.2.linux-arm64.tar.gz» guardado [108861264/108861264] remove_old_link: not found symlink for old install previous install renamed to: /usr/local/go-20220514-181752 untar: tar -x -f /usr/local/go1.18.2.linux-arm64.tar.gz profile_path_add: issuing new /usr/local/go/bin to /etc/profile.d/ profile_path_add: issuing $HOME/go/bin to /etc/profile.d/ golang go1.18.2.linux-arm64 installed at: /usr/local/go testing: /usr/local/go/bin/go version unsudo: running_as_root:ruben: /usr/local/go/bin/go version go version go1.18.2 linux/arm64 /usr/local/go/bin/go version: SUCCESS unsudo: running_as_root:ruben: mktemp -t hello-tmpXXXXXXXX unsudo: running_as_root:ruben: tee /tmp/hello-tmp9WG8G3Es.go testing: /usr/local/go/bin/go run /tmp/hello-tmp9WG8G3Es.go unsudo: running_as_root:ruben: /usr/local/go/bin/go run /tmp/hello-tmp9WG8G3Es.go hello, world - go1.18.2 /usr/local/go/bin/go run /tmp/hello-tmp9WG8G3Es.go: SUCCESS running_as_root: yes recursively forcing build cache [/home/ruben/.cache/go-build] ownership to 1000:1000 remember to delete previous install saved as: /usr/local/go-20220514-181752 HINT: If this is the first time you run this script, the env vars       updated in the profile will only take effect for new shells.       If you want them to affect the current shell, use this:       source /etc/profile.d/ 

$ go version

go version go1.18.2 linux/arm64

To finish the setup, the shell PATH should be updated.

  • The path ‘/usr/local/go/bin’ is added to PATH using ‘/etc/profile.d/’.
  • Only if needed, GOROOT is properly setup, also using ‘/etc/profile.d/’.
  • Alternatively, can be edited manually to .bashrc or .zshrc:
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *