# How to Install Go and the Current Version in Ubuntu Precise: A Complete Build Guide

> Install Go on Ubuntu Precise by compiling the toolchain from source. This build guide uses srcmakebash to create the compiler and standard library without system package dependencies.

- Repository: [Go/go](https://github.com/golang/go)
- Tags: how-to-guide
- Published: 2026-02-11

---

**To install Go on Ubuntu Precise, compile the toolchain from source using the [`src/make.bash`](https://github.com/golang/go/blob/main/src/make.bash) bootstrap script, which builds the compiler and standard library without relying on outdated system packages.**

Ubuntu Precise Pangolin (12.04) reached end-of-life years ago, and the official Go binary packages for this release are no longer maintained. If you need to install Go and verify the current version on this legacy system, building from the upstream `golang/go` repository is the only reliable path forward.

## Why Build From Source on Ubuntu Precise?

The Go project explicitly warns against using distribution-provided packages for older Ubuntu releases. In [`src/make.bash`](https://github.com/golang/go/blob/main/src/make.bash) at lines 100–101, the build script contains a check that warns when the system Go version may be broken or too old for bootstrapping. Since Ubuntu Precise repositories contain severely outdated Go versions (if any), the [`make.bash`](https://github.com/golang/go/blob/main/make.bash) script will fall back to using the C compiler to build the initial bootstrap toolchain.

## Prerequisites for Building Go

Before compiling, ensure your system has the necessary build tools. The bootstrap process requires a functional C toolchain (`gcc`, `make`) and Git to clone the repository.

```bash
sudo apt-get update
sudo apt-get install -y build-essential git wget

```

## Step-by-Step Installation Guide

### 1. Clone the Go Source Repository

Download the latest stable source into a working directory. The `master` branch typically points to the current development tip, while release tags (e.g., `go1.22.0`) provide stable versions.

```bash
git clone https://go.googlesource.com/go $HOME/go-src
cd $HOME/go-src/src

```

### 2. Run the Bootstrap Build Script

The heart of the installation is [`src/make.bash`](https://github.com/golang/go/blob/main/src/make.bash). This script orchestrates the entire build process:

- **Detects a bootstrap compiler** — It searches for an existing Go binary (`go1.4` or newer) in `$PATH`. If none exists (typical for a fresh Precise install), it compiles a small C-based bootstrap program.
- **Compiles the toolchain** — It builds the Go compiler (`cmd/compile`), the linker (`cmd/link`), and the standard library.
- **Installs the binary** — The final `go` executable is placed in `$HOME/go-src/bin`.

Execute the build:

```bash
./make.bash

```

Successful output resembles:

```text
Building Go cmd/dist using /usr/bin/gcc.
Building Go toolchain1 using /home/user/go-src.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go cmd/go using go_bootstrap and Go toolchain2.
---
Installed Go for linux/amd64 in /home/user/go-src
Installed commands in /home/user/go-src/bin

```

### 3. Configure Your Environment

Add the newly built Go binary to your system `PATH` and set `GOROOT` to point to the source tree.

```bash
export GOROOT=$HOME/go-src
export PATH=$GOROOT/bin:$PATH

```

Persist these settings by adding them to `~/.profile` or `~/.bashrc`:

```bash
echo 'export GOROOT=$HOME/go-src' >> ~/.profile
echo 'export PATH=$GOROOT/bin:$PATH' >> ~/.profile

```

### 4. Verify the Current Version

The `go` command reports its version through the implementation in [`src/cmd/go/main.go`](https://github.com/golang/go/blob/main/src/cmd/go/main.go). This file handles the `version` subcommand by reading the version string embedded during the build process.

```bash
go version

```

Output confirms the installation:

```text
go version go1.22.0 linux/amd64

```

## Understanding the Build Process

The [`src/make.bash`](https://github.com/golang/go/blob/main/src/make.bash) script is entirely self-contained. According to the `golang/go` source code, it performs the following technical steps:

1. **Bootstrap Detection**: Checks for `go1.4` or later in `$PATH`. If absent, it compiles `cmd/dist` using the system C compiler (`gcc`).
2. **Toolchain Construction**: Uses the bootstrap compiler to build `cmd/compile` (the Go compiler), `cmd/link` (the linker), and the runtime packages located in `src/runtime/`.
3. **Final Installation**: Copies the `go` binary to `$GOROOT/bin` and validates the directory structure against the layout defined in `doc/go1.22` (or the latest release documentation).

This process ensures that even on legacy systems like Ubuntu Precise, you obtain a fully functional, up-to-date Go toolchain that reports the correct version via [`src/cmd/go/main.go`](https://github.com/golang/go/blob/main/src/cmd/go/main.go).

## Summary

- **Ubuntu Precise lacks maintained Go packages**, necessitating a source build using [`src/make.bash`](https://github.com/golang/go/blob/main/src/make.bash).
- **The bootstrap script** detects existing Go compilers or falls back to C compilation to build the toolchain.
- **Key files** include [`src/make.bash`](https://github.com/golang/go/blob/main/src/make.bash) (build orchestration) and [`src/cmd/go/main.go`](https://github.com/golang/go/blob/main/src/cmd/go/main.go) (version reporting).
- **Environment setup** requires setting `GOROOT` to the source tree and adding `$GOROOT/bin` to `PATH`.
- **Verification** is done via `go version`, which reads the embedded version string from the build.

## Frequently Asked Questions

### Can I install Go on Ubuntu Precise using apt-get?

No. The official Ubuntu Precise repositories no longer maintain up-to-date Go packages, and the versions available are too old to bootstrap modern Go releases. The [`src/make.bash`](https://github.com/golang/go/blob/main/src/make.bash) script explicitly warns against using broken distribution packages at lines 100–101. Building from the `golang/go` source repository is the only supported method.

### What is the minimum C compiler version required to build Go?

The build process only requires a functional C toolchain (`gcc`, `make`) capable of compiling standard C code. There is no strict version requirement, but `gcc` 4.6 or later (available in Ubuntu Precise) is sufficient to compile the initial bootstrap `cmd/dist` program when no existing Go installation is present.

### Where is the go version string defined in the source code?

The `go version` command is implemented in [`src/cmd/go/main.go`](https://github.com/golang/go/blob/main/src/cmd/go/main.go), which parses the version subcommand and prints the version string. The actual version value (e.g., `go1.22.0`) is embedded into the binary during the build process by [`src/make.bash`](https://github.com/golang/go/blob/main/src/make.bash), which reads it from the repository tags or version files in the `VERSION` file at the repository root.

### How do I update Go to a newer version after building from source?

To upgrade, navigate to your source directory (`$HOME/go-src`), fetch the latest changes using `git fetch --tags`, checkout the desired release tag (e.g., `git checkout go1.23.0`), and rebuild by running [`./make.bash`](https://github.com/golang/go/blob/main/./make.bash) from the `src/` directory. The new binary will replace the old one in `$GOROOT/bin`, and `go version` will immediately reflect the update.