Noble Numbat comes with golang-defaults (2:1.22~2build1)
which brings in golang-1.22-go
.
However, this version is slightly outdated as Go 1.24 has already been released.
Each major Go release is supported until there are two newer major releases. For example, Go 1.5 was supported until the Go 1.7 release, and Go 1.6 was supported until the Go 1.8 release.
Of course you can simply run sudo snap install go --classic
to get the latest and greatest version of the Go compiler and toolchain. But what if, for some reason, you need a .deb
dependency for your project?
In this guide we’ll use a PPA to host our source packages and binaries. Please refer to the Launchpad documentation to set up your PPA.
- Prepare an isolated environment (in this case, an LXD container)
❯ lxc launch ubuntu:noble backporter
- Mount your GPG key inside the container
❯ lxc config set backporter raw.idmap "both 1000 1000"
❯ lxc config device add backporter gpg disk source=/home/troyanov/.gnupg path=/home/ubuntu/.gnupg
❯ lxc restart backporter
- Install utilities needed for backporting
❯ lxc shell backporter
❯ sudo add-apt-repository universe
❯ sudo apt install -y ubuntu-dev-tools devscripts
- Backporting Go 1.24.4 from Debian is very straightforward with backportpackage
❯ DEBFULLNAME='Anton Troyanov' \
DEBEMAIL='[email protected]' \
backportpackage -d noble -u ppa:troyanov/misc \
http://ftp.debian.org/debian/pool/main/g/golang-1.24/golang-1.24_1.24.4-1.dsc
- Update the
golang-defaults
dependency version
❯ dget -u https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/golang-defaults/2:1.22~2/golang-defaults_1.22~2.dsc
❯ cd golang-defaults-1.22~2/
❯ DEBFULLNAME='Anton Troyanov' DEBEMAIL='[email protected]' \
dch -v 2:1.24
- Select your editor of choice, change
UNRELEASED
tonoble
and add something to the changelog, e.g.
* Update to Go 1.24 (src:golang-1.24)
- Build, sign and upload the source package
❯ cd ../golang-defaults-1.24/
❯ sudo apt-get -y build-dep .
❯ DEBFULLNAME='Anton Troyanov' DEBEMAIL='[email protected]' \
debuild -S
❯ cd ..
❯ DEBFULLNAME='Anton Troyanov' DEBEMAIL='[email protected]' \
dput ppa:troyanov/misc golang-defaults_1.24_source.changes
Once you’ve completed the above steps, just be patient and wait while Launchpad is building your packages.
After packages are built and published you can use Go 1.24:
❯ sudo add-apt-repository ppa:troyanov/misc
❯ sudo apt update
❯ apt list -a golang-go
Listing... Done
golang-go/noble 2:1.24 amd64
golang-go/noble 2:1.22~2build1 amd64