Contents
When installing Go (Golang) on Enterprise Linux systems, the default package repositories are usually behind the official Go release cycle. This can cause compatibility issues when compiling modern projects or building statically linked binaries.
This guide walks through a proper, official installation method using the Go project’s own binaries. The result is a clean, system-wide Go installation that is safe to re-run and suitable for development, automation, and production tooling.
Why Not Use dnf install golang?
While Go is available in most RHEL-based repositories, it comes with drawbacks:
-
Versions are often several releases behind
-
Not ideal for modern Go modules
-
Poor choice for building portable or static binaries
For serious development, the official Go tarball is the correct approach.
Installation Overview
This method:
-
Installs Go from go.dev
-
Removes any existing distro Go packages
-
Sets system-wide environment variables
-
Creates a clean Go workspace
-
Is safe to re-run at any time
Go Installation Script
Save the following as install-go.sh:
Running the Installer
After installation, open a new shell and verify:
Expected output:
Go Environment Layout
This installation follows Go best practices:
| Variable | Purpose |
|---|---|
GOROOT |
Go installation directory |
GOPATH |
User workspace (~/go) |
PATH |
Includes Go binaries |
Workspace structure:
Why This Method Works Well
-
Uses official Go binaries
-
Avoids stale distro packages
-
Safe for CI, servers, and desktops
-
Clean system-wide configuration
-
Ideal for compiling tools and static binaries
Final Notes
-
This method works on Rocky Linux, RHEL, AlmaLinux, and CentOS
-
Updating Go later is as simple as changing the version and re-running the script
-
Perfect foundation for building Go-based CLI tools, monitors, and services