Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk10 min

How to Build Go from Source on a Linux VPS

Compile a reproducible Go toolchain on a Linux VPS with the correct bootstrap compiler, a pinned source checkout, make.bash, optional cgo support, cross-target settings and practical verification steps.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To build Go from source on a Linux VPS, install Git and a compatible bootstrap Go compiler, clone the official Go repository into a dedicated directory, check out a release tag, then run cd src followed by ./make.bash. Add the checkout’s generated bin directory to PATH and compile a small program to verify the result. A C compiler is needed only when the toolchain must support cgo.

What a source build gives you

A source build creates a Go toolchain directly from a selected revision of the Go source tree. The resulting compiler, linker and go command are installed inside the checkout directory, with executables in its bin subdirectory. You control the exact release tag or commit, can build a modified tree, and can target combinations for which a ready-made archive is unavailable.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For an ordinary Linux VPS installation, a precompiled package is usually faster and simpler. The Go project describes binary installation as the normal path for most users. Building from source is most useful when you need a reproducible, pinned toolchain; are working on Go itself; require a source modification; or need an operating-system and architecture combination without a suitable binary distribution.

Prerequisites on the VPS

Git

Git is required to fetch the repository and select the revision you intend to build. Install it with the package manager for your Linux distribution before running the clone command. The source procedure itself does not depend on a particular distribution package name, so use the package name supplied by your distribution.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

A bootstrap Go compiler

The Go toolchain is written in Go, so compiling a new toolchain requires an existing Go compiler. The build scripts first look for go in PATH. If the bootstrap compiler is installed elsewhere, set GOROOT_BOOTSTRAP; the scripts then use $GOROOT_BOOTSTRAP/bin/go.

The minimum bootstrap version depends on the release you are building. Match the source release to this table before starting:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Go release being built Minimum bootstrap compiler
Go 1.5 through 1.19 Go 1.4
Go 1.20 through 1.21 Go 1.17
Go 1.22 through 1.23 Go 1.20
Future Go 1.N releases Go 1.M, where M is N minus 2, rounded down to an even number
Example: Go 1.24 or Go 1.25 Go 1.22

These are minimum requirements, not a recommendation to use an arbitrarily old compiler. If the release you select has a newer documented bootstrap requirement, use that requirement. Verify the compiler you will use with go version, and make sure the command resolves to the intended installation rather than a distribution copy left earlier in PATH.

Optional C compiler for cgo

Install a C compiler such as GCC or Clang when programs built with the resulting toolchain must support cgo. A source build does not require a C compiler when you deliberately build with cgo disabled. Set CGO_ENABLED=0 before invoking the build script for that case.

Choose an installation directory

Use a clean directory whose final Go source directory does not already exist. The official instructions use a directory named goroot. That name helps avoid a common ambiguity: $HOME/go is also the conventional default for GOPATH, so placing the Go source tree there can make it harder to distinguish the toolchain from workspace content.

The build installs into the checkout itself. It does not automatically replace a system installation under /usr/local/go, and you should not assume that path when compiling in a custom location. Record the absolute path of the checkout so that your service units, shell profile and maintenance notes all refer to the same toolchain.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Fetch the source and pin the release

Clone the official repository into the dedicated directory, then check out a release tag or release branch. Replace <tag> with the exact tag you have selected:

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.
git clone https://go.googlesource.com/go goroot
cd goroot
git checkout <tag>

The clone URL above is the official Go source repository. A release tag makes the build reproducible: another administrator can inspect the checkout and rebuild the same version later. For production work, record both the human-readable tag and the commit shown by git rev-parse HEAD after checkout.

Use the master branch only when your purpose is Go development or testing changes that have not yet been released. For a normal VPS toolchain, stay on a release tag or a maintained release branch rather than building whatever happens to be current on master.

Build the toolchain

Standard build

From the root of the checkout, enter src and run the build script:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
cd goroot/src
./make.bash

A successful run reports the target platform, installation root and command directory, then reminds you to add the new bin directory to PATH. Treat that output as authoritative for the actual installation path; it is safer than assuming a conventional system directory.

The script builds the toolchain for the host platform by default. Keep the terminal output or redirect it to an operational log if you need an audit trail for the VPS.

Build and run the longer test suite

Use ./all.bash instead of ./make.bash when you want the build plus the standard, longer test run:

cd goroot/src
./all.bash

all.bash takes longer because it exercises the newly built toolchain and runs important tests. It is appropriate before promoting a compiler to a production role or after changing an existing source tree. A plain make.bash is the shorter choice when you only need the binaries and have separate testing arrangements.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

Complete shell outline

The following sequence shows the order without assuming a system-wide installation:

# Git and a compatible bootstrap Go must already be available
# Install gcc or clang first if cgo support is required

git clone https://go.googlesource.com/go goroot
cd goroot
git checkout <release-tag>
cd src
./make.bash
export PATH="$PWD/../bin:$PATH"
go version

Because the export is run while the shell is in goroot/src, $PWD/../bin points to the checkout’s generated command directory. Adapt it if you change directories or use a different installation location. To make the compiler available in future login sessions, put an equivalent export in the profile used by the account that will run Go programs, and verify the profile does not later prepend a different Go installation.

Build without cgo

For a toolchain intended to build pure-Go programs without C interoperability, disable cgo explicitly:

cd goroot/src
CGO_ENABLED=0 ./make.bash

The setting applies to this invocation. If you use all.bash for the no-cgo build, set it in the same way:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
CGO_ENABLED=0 ./all.bash

Disabling cgo does not turn a source build into a cross-compiler by itself; it only controls C interoperability. Programs that depend on C libraries or cgo-specific packages will need a toolchain built and configured with cgo support instead.

Verify that the new compiler is the one being used

Check the command and version

After updating PATH, inspect the command selected by the shell and print its version:

command -v go
go version

The path should point into the checkout’s bin directory, and the version should match the release tag you checked out. If another path appears first, adjust PATH or use the absolute path to the newly built executable while diagnosing the environment.

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.

Compile a smoke-test program

Create a file named hello.go:

package main

import "fmt"

func main() {
    fmt.Printf("hello, worldn")
}

Run it with the new command:

go run hello.go

The expected output is:

hello, world

This test confirms more than the presence of an executable: the selected go command can locate its installation, compile source and execute the resulting program. If the command reports an unexpected version, fix PATH before investigating the source tree.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Selecting targets with GOOS and GOARCH

GOOS and GOARCH describe the operating system and architecture for which the resulting binaries run. They are target settings, not a description of the VPS host alone. Set them deliberately when building for another machine.

Linux-capable targets listed by the Go source documentation include:

  • GOARCH=amd64
  • GOARCH=386
  • GOARCH=arm64
  • GOARCH=arm
  • GOARCH=loong64
  • GOARCH=mips and the other supported MIPS variants
  • GOARCH=ppc64 and the supported PPC64 variants
  • GOARCH=riscv64
  • GOARCH=s390x

Not every operating-system and architecture pair is supported. Confirm the pair for the release you selected before starting a long VPS build, and remember that cgo introduces additional target-specific C compiler requirements.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Cross-building a bootstrap tree

The official bootstrap example sets the target before running bootstrap.bash:

GOOS=linux GOARCH=ppc64 ./bootstrap.bash

This creates a bootstrap tree for the requested target. Copy that tree to the target machine and point the target build at it with GOROOT_BOOTSTRAP. For example, if the copied tree is /opt/go-bootstrap, the build environment can select it with:

export GOROOT_BOOTSTRAP=/opt/go-bootstrap

The bootstrap tree supplies the compiler used to build the final source checkout; it is not automatically the location from which your applications should run. Keep the bootstrap and final toolchain directories distinct so an update cannot accidentally overwrite the compiler needed for the next build.

Updating an existing source-built Go tree

When a newer release is available, retain the current working compiler until the replacement passes your checks. The documented update sequence is:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
cd go/src
git fetch
git checkout <tag>
./all.bash

Use the actual path to your checkout; the example assumes a directory named go. Run the update during a maintenance window if production services depend on the toolchain. Keep the old checkout or its binaries until the new version passes go version, the hello.go smoke test and any tests required by your build pipeline. Removing the old tree is an operational decision, not a prerequisite of the Go build.

If you have local modifications, review them before switching tags. A release checkout is easier to reproduce than a tree containing unrecorded changes, so document intentional patches and the commit on which they are based.

Troubleshooting common failures

The script cannot find a bootstrap compiler

Run go version in the same shell used for the build. If it fails, install or expose a compatible compiler in PATH. If the compiler is installed in a nonstandard directory, set GOROOT_BOOTSTRAP to its root and confirm that $GOROOT_BOOTSTRAP/bin/go exists. A compiler that is present but older than the release’s minimum requirement will not satisfy the bootstrap check; use the version from the matrix instead.

The wrong Go version appears after the build

Shells use the first matching executable in PATH. Run command -v go and compare the result with the checkout’s bin/go. Export the checkout path ahead of the system path, start a new login shell if your profile changed, and run go version again.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

cgo-related errors

If the resulting toolchain or its programs must use cgo, install GCC or Clang and the C headers and libraries required by the target platform. If C interoperability is not needed, rebuild with CGO_ENABLED=0 rather than trying to repair a missing C toolchain.

A checkout is in the wrong state

Use git status to identify local changes, then check out the intended release tag explicitly. Record the resulting commit. Building from an unpinned branch can silently change the compiler when you fetch later, which defeats a reproducible VPS deployment.

Tests take too long

./all.bash intentionally performs more work than ./make.bash. If you only need a local compiler, use the shorter script; if the toolchain will be promoted or you changed source code, schedule the longer test run rather than treating its duration as a build failure.

Source build or precompiled binary?

Situation Better starting point Reason
Standard supported Linux VPS installation Precompiled binary It is the quicker, simpler installation path and avoids the bootstrap step.
Need an exact release tag or commit Source build The checkout can be pinned and recorded for reproducibility.
Contributing to or modifying Go Source build You need the repository and its build/test scripts.
No binary distribution for the OS/architecture Source build The repository source-install procedure is the fallback for unsupported binary combinations.
Need a quick compiler with no customization Precompiled binary There is no reason to pay the time and maintenance cost of compilation.

When installing a fresh precompiled archive, the official download guidance recommends removing an old /usr/local/go tree before extraction. That advice applies to binary installation, not to a source checkout in a custom directory. Do not delete a working source-built tree merely because a binary guide uses that path.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Operational checklist for a VPS

  • Install Git and confirm a compatible bootstrap Go compiler.
  • Install GCC or Clang only if cgo support is required.
  • Use a clean checkout directory that is not confused with the default GOPATH.
  • Clone the official repository and check out a release tag or documented release branch.
  • Record the tag and exact commit used for the build.
  • Run cd src and ./make.bash, or use ./all.bash when the longer test run is required.
  • Use CGO_ENABLED=0 explicitly for a no-cgo build.
  • Set GOOS and GOARCH only after deciding where the resulting binaries must run.
  • Add the generated bin directory to PATH using the path printed by the build.
  • Check command -v go and go version.
  • Run the hello.go smoke test and retain the old compiler during an upgrade until validation succeeds.

Final recommendation

A pinned source build is a controlled deployment technique, not the default way to install Go. On a Linux VPS, use it when version control, source changes, development work or an unavailable binary target justifies the additional steps. The reliable sequence is to satisfy the bootstrap requirement, pin the checkout, build with the appropriate cgo and target settings, expose the generated bin directory, and verify it with both go version and a runnable program.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.