Debian’s default Go package is stable, but it falls behind upstream quickly when you need newer language features or toolchain fixes. If you need to install Go on Debian for APIs, command-line tools, or backend services, the best method depends on whether you want Debian-managed updates or the current upstream release.
Default Debian package sources currently ship Go 1.24.x on Debian 13, Go 1.19.x on Debian 12, and Go 1.15.x on Debian 11. You can stay with the Debian APT package for the distro-managed route, or switch to the official tarball from go.dev or a source build when you need a newer or patchable toolchain. The same workflow also covers PATH setup, updates, troubleshooting, and removal.
Install Go on Debian
Three installation paths are available on Debian. APT is the easiest to maintain, the official tarball tracks the latest stable Go release, and source builds are mainly useful when you need to patch or inspect the toolchain itself.
| Method | Channel | Version | Updates | Best For |
|---|---|---|---|---|
| APT | Debian Repos | Debian 13: 1.24.x, Debian 12: 1.19.x, Debian 11: 1.15.x | Automatic through APT | Stable systems that prefer distro-managed packages |
| Official Tarball | go.dev downloads | Latest stable | Manual reinstall | Developers who want the latest upstream toolchain |
| Source Build | Go source tree | Latest stable or chosen tag | Manual rebuild | Contributors and users patching Go itself |
If you want the shortest route to a decision, use this quick pick before you move into the install steps.
- APT for stability: Stick with Debian’s package when Debian 13’s Go 1.24.x, Debian 12’s Go 1.19.x, or Debian 11’s Go 1.15.x is already new enough for your projects.
- Official tarball for the latest release: Use the upstream archive when you want the current stable toolchain and do not mind reinstalling it during upgrades.
- Source build for toolchain work: Keep this path for patching Go, inspecting the source tree, or testing a specific upstream release tag.
Update Debian and install Go prerequisites
Refresh package metadata first so each install method starts from a current Debian system.
sudo apt update && sudo apt upgrade
These commands use
sudofor root privileges. If your account does not have sudo access yet, follow how to add a user to sudoers on Debian.
Install the tools used by the tarball method first. Desktop systems often already have them, but server and minimal installs usually do not.
sudo apt install ca-certificates curl tar
Install Go from Debian APT on Debian
The Debian package is the lowest-maintenance option because APT keeps it updated with the rest of your system. The package name is golang-go, but the command it installs is still go.
sudo apt install golang-go
Verify which Go release Debian installed.
go version
go version go1.24.4 linux/amd64 # Debian 13 go version go1.19.8 linux/amd64 # Debian 12 go version go1.15.15 linux/amd64 # Debian 11
APT users can skip the PATH configuration section later in the article because Debian already exposes the
gobinary through/usr/bin/go.
Install Go from the official tarball on Debian
The official tarball is the better choice when you need the latest stable release from upstream instead of Debian’s older packaged branch.
Check your Debian architecture first so the download command picks the right Go archive. The block below maps Debian’s package architecture names to the filenames published on go.dev, then stops with a clear error for architectures that need manual selection.
dpkg --print-architecture
amd64
Download the latest stable Go tarball from the JSON metadata endpoint. This avoids scraping HTML and keeps the command current as new Go releases ship.
GO_VERSION=$(curl -fsSL https://go.dev/dl/?mode=json 2>/dev/null | sed -n '/"version"/{s/.*"version": "\(go[0-9.]*\)".*/\1/p;q;}')
case "$(dpkg --print-architecture)" in
amd64) GO_ARCH=amd64 ;;
arm64) GO_ARCH=arm64 ;;
i386) GO_ARCH=386 ;;
*) echo "Choose the correct tarball manually from https://go.dev/dl/ for this Debian architecture." && exit 1 ;;
esac
GO_TARBALL="${GO_VERSION}.linux-${GO_ARCH}.tar.gz"
curl -fL --progress-bar -o "/tmp/${GO_TARBALL}" "https://go.dev/dl/${GO_TARBALL}"
echo "$GO_TARBALL"
go1.x.x.linux-amd64.tar.gz
Run the extraction commands in the same terminal session so $GO_TARBALL still points to the file you just downloaded.
If you already have an older tarball install in
/usr/local/go, remove it before extracting the new release so you do not mix files from different versions.
sudo rm -rf /usr/local/go
Extract the new toolchain into /usr/local and remove the downloaded archive after the install finishes.
sudo tar -C /usr/local -xzf "/tmp/${GO_TARBALL}"
rm -f "/tmp/${GO_TARBALL}"
Confirm the tarball install is in place before you add it to your PATH.
/usr/local/go/bin/go version
go version go1.x.x linux/amd64
Build Go from source on Debian
A source build is mainly for people who want to patch Go or work directly from the upstream tree. Current Go releases need a recent bootstrap compiler, so the simplest path is to complete the official tarball method first and then reuse /usr/local/go as GOROOT_BOOTSTRAP.
Keep the source tree under your home directory instead of /tmp. That matches upstream guidance more closely, avoids cleanup races, and gives the build a normal writable tree that persists across shells.
Source builds also need Git for the upstream checkout and GCC for cgo-enabled packages.
sudo apt install git gcc
GO_VERSION=$(curl -fsSL https://go.dev/dl/?mode=json 2>/dev/null | sed -n '/"version"/{s/.*"version": "\(go[0-9.]*\)".*/\1/p;q;}')
rm -rf "$HOME/goroot-src"
git clone --depth 1 --branch "$GO_VERSION" https://go.googlesource.com/go "$HOME/goroot-src"
Verify that the source tree is on the release tag you expect before you start the build.
git -C "$HOME/goroot-src" describe --tags --exact-match
go1.x.x
Build Go from the source tree by pointing GOROOT_BOOTSTRAP at the tarball install you already placed in /usr/local/go.
export GOROOT_BOOTSTRAP=/usr/local/go
cd "$HOME/goroot-src/src"
./make.bash
Installed Go for linux/amd64 in /home/username/goroot-src Installed commands in /home/username/goroot-src/bin *** You need to add /home/username/goroot-src/bin to your PATH. ***
Check the resulting binary from the source tree before you use it in your shell profile.
"$HOME/goroot-src/bin/go" version
go version go1.x.x linux/amd64
Configure Go on Debian
APT installs do not need extra PATH work, but tarball and source builds do. Most users also do not need to set GOPATH manually anymore because Go defaults to $HOME/go; adding $HOME/go/bin to your PATH is usually enough for tools installed with go install.
Add a tarball install to PATH on Debian
Use this profile entry when you installed Go under /usr/local/go.
grep -q '/usr/local/go/bin' ~/.profile || printf '\n# Go toolchain\nexport PATH=$PATH:/usr/local/go/bin:$HOME/go/bin\n' >> ~/.profile
source ~/.profile
Add a source build to PATH on Debian
Use this profile entry instead when you built Go in $HOME/goroot-src.
grep -q '/goroot-src/bin' ~/.profile || printf '\n# Go source build\nexport PATH=$PATH:$HOME/goroot-src/bin:$HOME/go/bin\n' >> ~/.profile
source ~/.profile
Verify the active Go binary on Debian
Check which binary your shell resolves first so you know whether APT, the tarball, or the source tree is active.
command -v go
go version
/usr/bin/go go version go1.24.x linux/amd64 /usr/local/go/bin/go go version go1.x.x linux/amd64 /home/username/goroot-src/bin/go go version go1.x.x linux/amd64
Verify Go on Debian with a test program
Build one small module before you move on to real work. That confirms the compiler, module support, and runtime are all working with the active Go binary on your PATH.
Create a test directory and initialize a module.
mkdir -p ~/go-hello
cd ~/go-hello
go mod init hello
go: creating new go.mod: module hello
Write a short program with printf so you can paste it directly without dealing with a heredoc.
printf '%s\n' 'package main' '' 'import "fmt"' '' 'func main() {' ' fmt.Println("Hello, World!")' '}' > hello.go
Run the program with the Go binary that is currently active in your shell.
go run hello.go
Hello, World!
Remove the test directory when you are done with it.
cd ~ && rm -rf ~/go-hello
Update Go on Debian
The update command depends on how you installed Go in the first place.
- APT users should keep the Debian package on the APT track.
- Tarball users should re-download the latest archive from
go.dev. - Source-build users should keep a reusable update script with the source tree so future upgrades stay repeatable.
Update the Debian APT package on Debian
Use APT’s single-package upgrade mode when you want Debian to update only the packaged Go toolchain.
sudo apt update && sudo apt install --only-upgrade golang-go
Confirm the package version after the upgrade finishes.
go version
go version go1.xx.x linux/amd64
Update the official tarball install on Debian
Tarball installs update by repeating the download and extraction flow with the latest archive from go.dev. Keep these commands in the same terminal session so the detected version and tarball filename stay available through the whole upgrade.
GO_VERSION=$(curl -fsSL https://go.dev/dl/?mode=json 2>/dev/null | sed -n '/"version"/{s/.*"version": "\(go[0-9.]*\)".*/\1/p;q;}')
case "$(dpkg --print-architecture)" in
amd64) GO_ARCH=amd64 ;;
arm64) GO_ARCH=arm64 ;;
i386) GO_ARCH=386 ;;
*) echo "Choose the correct tarball manually from https://go.dev/dl/ for this Debian architecture." && exit 1 ;;
esac
GO_TARBALL="${GO_VERSION}.linux-${GO_ARCH}.tar.gz"
curl -fL --progress-bar -o "/tmp/${GO_TARBALL}" "https://go.dev/dl/${GO_TARBALL}"
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf "/tmp/${GO_TARBALL}"
rm -f "/tmp/${GO_TARBALL}"
Verify the upgraded tarball toolchain directly from its install path.
/usr/local/go/bin/go version
go version go1.x.x linux/amd64
Source builds follow the same release cadence as the tarball, but they deserve their own update path because the tree stays under your home directory and does not update through APT.
Create a Go source update script on Debian
Source builds are easier to maintain when you keep one reusable script next to the source tree. This version checks for required tools, confirms the source tree and bootstrap compiler exist, skips the rebuild when you are already current, and then updates the checkout to the latest stable tag.
cat > "$HOME/update-go-source.sh" <<'EOF'
#!/usr/bin/env bash
set -euo pipefail
SOURCE_DIR="$HOME/goroot-src"
BOOTSTRAP_ROOT="/usr/local/go"
LOG_FILE="$HOME/goroot-src-update.log"
if [ "$(id -u)" -eq 0 ]; then
echo "Run this script as a regular user. The source build in $HOME should stay owned by your user."
exit 1
fi
for cmd in curl git; do
if ! command -v "$cmd" >/dev/null 2>&1; then
echo "Error: $cmd is required but not installed."
exit 1
fi
done
if [ ! -d "$SOURCE_DIR/.git" ]; then
echo "Error: $SOURCE_DIR does not contain the Go source tree."
echo "Build Go from source first so this script has a checkout to update."
exit 1
fi
if [ ! -x "$BOOTSTRAP_ROOT/bin/go" ]; then
echo "Error: $BOOTSTRAP_ROOT/bin/go was not found."
echo "Install or reinstall the official Go tarball first so GOROOT_BOOTSTRAP is available."
exit 1
fi
if [ -n "$(git -C "$SOURCE_DIR" status --porcelain)" ]; then
echo "Error: $SOURCE_DIR has uncommitted changes."
echo "Commit, stash, or discard them before running the update script."
exit 1
fi
LATEST_TAG=$(curl -fsSL https://go.dev/dl/?mode=json 2>/dev/null | sed -n '/"version"/{s/.*"version": "\(go[0-9.]*\)".*/\1/p;q;}')
if [ -z "$LATEST_TAG" ]; then
echo "Error: Could not detect the latest Go release from go.dev."
exit 1
fi
CURRENT_TAG=$(git -C "$SOURCE_DIR" describe --tags --exact-match 2>/dev/null || echo none)
echo "Current tag: $CURRENT_TAG"
echo "Latest tag: $LATEST_TAG"
if [ "$CURRENT_TAG" = "$LATEST_TAG" ]; then
echo "Go source build is already up to date."
exit 0
fi
echo "Fetching the latest Go tags..."
git -C "$SOURCE_DIR" fetch --tags
echo "Checking out $LATEST_TAG..."
git -C "$SOURCE_DIR" checkout "$LATEST_TAG"
echo "Building Go from source..."
export GOROOT_BOOTSTRAP="$BOOTSTRAP_ROOT"
cd "$SOURCE_DIR/src"
./make.bash | tee "$LOG_FILE"
echo "Verifying the updated source build..."
"$SOURCE_DIR/bin/go" version
echo "Go source build updated to $LATEST_TAG."
EOF
Make the script executable before you try to run it. The script also writes its build output to $HOME/goroot-src-update.log, which gives you one place to review failures later.
chmod +x "$HOME/update-go-source.sh"
Run the update script manually whenever you want to rebuild the source tree against the latest stable Go tag.
~/update-go-source.sh
Current tag: go1.x.x Latest tag: go1.x.x Go source build is already up to date.
When the script finds a newer release, verify the resulting source-built binary from the checkout itself.
"$HOME/goroot-src/bin/go" version
go version go1.x.x linux/amd64
Avoid running this script from cron. Source builds can fail because of network issues, toolchain regressions, or local dependency problems, so run it manually and review the output before replacing the toolchain you rely on.
Troubleshoot Go on Debian
Most Go problems on Debian come from PATH mismatches, mixed installation methods, or missing build tools.
Fix go command not found on Debian
Start by checking whether your shell can resolve the go binary at all.
command -v go || echo 'go not found'
go not found
If you installed Go from Debian packages, confirm the package is still present.
dpkg-query -W -f='${Status} ${Version}\n' golang-go 2>/dev/null
install ok installed 2:1.xx~1
If you installed the tarball or a source build, check the binaries those methods create.
ls /usr/local/go/bin/go "$HOME/goroot-src/bin/go" 2>/dev/null
/usr/local/go/bin/go /home/username/goroot-src/bin/go
When the binary exists but the shell still cannot find it, reload your profile and check the resolved path again.
source ~/.profile
command -v go
/usr/local/go/bin/go
Fix mixed APT and tarball Go versions on Debian
Two Go installs usually show up as multiple paths in which -a go. That leaves your shell using whichever path appears first.
which -a go
/usr/local/go/bin/go /usr/bin/go
If you want to keep the newer tarball release, remove the Debian package so the older binary stops competing for your PATH.
sudo apt purge golang-go golang-src && sudo apt autoremove --purge
If you want to go back to Debian’s packaged toolchain instead, remove the tarball directory and drop its PATH line from ~/.profile.
sudo rm -rf /usr/local/go
sed -i '\|/usr/local/go/bin|d' ~/.profile
source ~/.profile
Fix gcc missing during Go builds on Debian
Go itself can build without C code in some cases, but many Go projects and cgo-dependent tools still need gcc available.
sudo apt install gcc
gcc --version | head -n 1
gcc (Debian 12.x.x-xx) 12.x.x
Remove Go from Debian
Remove the Go method you actually installed. APT, tarball, and source builds clean up differently.
Remove the Debian APT package on Debian
Purge the Debian package and then let APT remove any dependencies that are no longer needed.
sudo apt update && sudo apt purge golang-go golang-src && sudo apt autoremove --purge
Verify that Debian no longer sees Go as installed.
apt-cache policy golang-go
golang-go:
Installed: (none)
Candidate: 2:1.xx~1
Version table:
2:1.xx~1 500
500 http://deb.debian.org/debian your-release/main amd64 Packages
The version and release name in that output vary by Debian release, but Installed: (none) is the key success line.
Remove tarball or source Go installs on Debian
Tarball installs live in /usr/local/go, and source builds typically live in $HOME/goroot-src.
The
$HOME/goworkspace contains downloaded modules, compiled binaries, and any tools you installed withgo install. Remove it only if you no longer need that cached data or those binaries.
sudo rm -rf /usr/local/go
rm -rf "$HOME/goroot-src" "$HOME/go" "$HOME/.cache/go-build" "$HOME/go-hello"
Remove the PATH entries from your shell profile so a new terminal does not keep pointing at a deleted Go binary.
sed -i '\|/usr/local/go/bin|d;\|/goroot-src/bin|d' ~/.profile
source ~/.profile
Use a path-specific check here so Debian’s packaged /usr/bin/go can stay installed without making the cleanup look incomplete.
ls /usr/local/go/bin/go "$HOME/goroot-src/bin/go" 2>/dev/null || echo 'custom Go binaries removed'
custom Go binaries removed
Go on Debian FAQ
Use Debian’s package when the distro version is new enough for your projects and you want updates managed through apt. Use the official tarball when you need the current upstream toolchain, because Debian 13 ships Go 1.24.x, Debian 12 ships Go 1.19.x, and Debian 11 ships Go 1.15.x from default APT sources.
Debian 12 ships Go 1.19.x from its default APT sources. For comparison, Debian 13 ships Go 1.24.x and Debian 11 ships Go 1.15.x, so the official tarball is the better route when you need a newer compiler on older Debian releases.
Usually no. Go uses $HOME/go as the default workspace, so most users only need a PATH entry for /usr/local/go/bin or $HOME/goroot-src/bin, plus $HOME/go/bin if they install extra tools with go install.
Your shell is still resolving another Go binary first, usually /usr/bin/go, or you have not reloaded ~/.profile yet. Check with which -a go, remove the method you no longer want, and reload the shell with source ~/.profile or open a new terminal session.
Conclusion
Go is installed on Debian with a verified toolchain, a working test module, and a clear update path whether you kept APT or moved to the upstream release. If your next step is real project work, pair it with Install Git on Debian for version control and Install Docker on Debian when you want to test containerized builds.
Why should we run sudo apt update && sudo apt upgrade if we didn’t use it?
Good question, R. Rahwana. Running
sudo apt update && sudo apt upgradebefore installing new software ensures your package lists are current and existing packages have the latest security patches. This prevents dependency conflicts and ensures tools likecurlandwgetwork correctly when downloading the Go tarball.It is technically optional if your system is already up to date, but including it in guides helps readers starting from minimal or freshly installed systems avoid unexpected issues.