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:
sudo apt remove --autoremove golang-go
Remove all current go installation you installed via aptsudo apt install snapd;
Install snap (Software packaging system by Canonical <= Folks behind ubuntu. Learn more)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.