How to install golang (go) >1.21 in Ubuntu with Snap

Install golang in a somewhat recent version in Ubuntu is quite annoying. Here a on-line command which will do the trick for you. (Replace 1.21 with whatever version of go you want to install)

sudo apt remove --autoremove golang-go; sudo apt install snapd; sudo snap install --classic --channel=1.21/stable go

What it does:

  1. sudo apt remove --autoremove golang-go Remove all current go installation you installed via apt
  2. sudo apt install snapd; Install snap (Software packaging system by Canonical <= Folks behind ubuntu. Learn more)
  3. sudo snap install --classic --channel=1.21/stable go Use snap to install golang

This works like a charm, and after hours of trying to make it work via the binary download “official” way mentioned on the golang.org this finally made my golang installation work.

To never miss an article subscribe to my newsletter
No ads. One click unsubscribe.