How to install Go on Windows, macOS, and Linux?
Aug 03, 2025 am 02:44 AMOn Windows, download the Go .msi installer from the official site, run it to install Go and set PATH automatically, then verify with go version in Command Prompt or PowerShell. 2. On macOS, either use the official .pkg installer from go.dev/dl/ or install via Homebrew with brew install go, which is recommended for easier updates, and verify with go version in Terminal. 3. On Linux, download the official tarball from go.dev/dl/, extract it to /usr/local with sudo tar -C /usr/local -xzf go*.tar.gz, add /usr/local/go/bin to PATH in shell config, then run source ~/.bashrc (or equivalent) and verify with go version; alternatively, use package managers like apt or dnf though they may provide older versions. After installation on any platform, verify setup by running go env and testing a simple program with go mod init, creating a hello.go file, and running go run hello.go to confirm output of "Hello, Go!".
Installing Go (Golang) is straightforward on Windows, macOS, and Linux. Here's how to do it on each operating system, with clear steps and practical tips.

1. Install Go on Windows
Go offers a simple installer for Windows that handles most of the setup.
Steps:

Download the installer
Go to the official Go downloads page and download the Windows installer (.msi
file) for your architecture (usually AMD64).-
Run the installer
Double-click the.msi
file and follow the prompts. The installer will:- Install Go to
C:\Program Files\Go
- Add Go to your system
PATH
automatically
- Install Go to
-
Verify installation
Open Command Prompt or PowerShell and run:go version
You should see output like:
go version go1.21.5 windows/amd64
Set up your workspace (optional)
By default, Go 1.16 doesn’t requireGOPATH
for modules, but if you're working in legacy mode, you might want to set it. For modern Go, just create a project folder anywhere.
2. Install Go on macOS
You can install Go on macOS using an official installer or a package manager like Homebrew.
Option A: Using the official installer
Download the macOS package
From go.dev/dl/, download the macOS installer (.pkg
file).Run the installer
Open the.pkg
file and follow the instructions. It installs Go to/usr/local/go
and adds it to yourPATH
if you’re using the default shell.Verify installation
Open Terminal and run:go version
Option B: Using Homebrew (recommended for developers)
Install Go with:
brew install go
This installs the latest stable version and manages updates easily.
Verify with:
go version
? Tip: If you use
zsh
(default on newer macOS), make sure your shell config (like~/.zshrc
) includes/usr/local/go/bin
inPATH
only if using the manual install. Homebrew usually handles this.
3. Install Go on Linux
Linux installation can be done via the official binary or your distro’s package manager.
Option A: Official binary (recommended for latest version)
Download the binary
Go to go.dev/dl/ and download the Linux tarball (e.g.,go1.21.5.linux-amd64.tar.gz
).Extract it to
/usr/local
Run these commands in your terminal:sudo rm -rf /usr/local/go # remove old version if exists sudo tar -C /usr/local -xzf go1.21.5.linux-amd64.tar.gz
Add Go to your
PATH
Add this line to your shell profile (~/.bashrc
,~/.zshrc
, or~/.profile
):export PATH=$PATH:/usr/local/go/bin
Then reload your shell config:
source ~/.bashrc # or ~/.zshrc
Verify installation
go version
Option B: Using package manager (easier but may be outdated)
Ubuntu/Debian:
sudo apt update sudo apt install golang-go
Fedora/RHEL:
sudo dnf install go
?? Note: Package manager versions are often behind. For the latest Go, use the official binary.
Final Checks (All Platforms)
After installing, run a quick test:
Check Go environment:
go env
Create a test program:
mkdir hello && cd hello go mod init hello
Create a file
hello.go
:package main import "fmt" func main() { fmt.Println("Hello, Go!") }
Run it:
go run hello.go
If you see "Hello, Go!", you're all set.
Basically, the process is simple: download the right package, install it, add to PATH
if needed, and verify. The official binary method gives you the latest version reliably across systems. Using package managers like brew
or apt
is convenient but may lag behind.
The above is the detailed content of How to install Go on Windows, macOS, and Linux?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Entering CSGO HD blockbuster mode requires four steps: 1. Update the game client to the latest version; 2. Adjust the video settings to the highest parameters; 3. Start the game and enter high-definition mode; 4. Optimize performance and test adjustments. Through these steps, you can improve the gaming experience of CSGO and enjoy a clearer picture and a more immersive gaming environment.

Two methods and precautions for downloading Binance on Android phones: 1. Download the APK file through the official website: visit Binance official website www.binance.com, click "Android APK Download", and enable the installation permission of the "Unknown Source" of your phone before completing the installation; 2. Download through a third-party application store: select a trusted store to search for "Binance", confirm the developer information and download and install it. Be sure to get the app from official channels, enable two-factor verification, regularly change passwords and be alert to phishing websites to ensure your account security.

How to safely download and install Ouyi OK APP? 1. Visit the official website: Use the Android browser to enter the official website and confirm it is the official website; 2. Find the download entrance: Click the "APP Download" button on the homepage; 3. Select the Android version: Select "Android Download" on the download page; 4. Download the APK file: Allow the browser to download APK installation packages from unknown sources; 5. Enable installation permissions: Go to the mobile phone settings to enable the "Unknown Source Application Installation" permission; 6. Complete the installation: Click the APK file to install, etc.

The method of installing PHP varies from operating system to operating system. The following are the specific steps: 1. Windows users can use XAMPP to install packages or manually configure them, download XAMPP and install them, select PHP components or add PHP to environment variables; 2. macOS users can install PHP through Homebrew, run the corresponding command to install and configure the Apache server; 3. Linux users (Ubuntu/Debian) can use the APT package manager to update the source and install PHP and common extensions, and verify whether the installation is successful by creating a test file.

As the world's leading cryptocurrency exchange, OKX provides a safe and reliable trading environment and a rich variety of digital assets. 1. Visit the official website www.okx.com to download the application; 2. Select the Android or iOS version according to the device; 3. Install the application and complete registration or login; 4. Enable two-factor verification to ensure account security. The platform supports spot trading, leveraged trading, contract trading, DeFi, OKX Earn financial management and NFT market.

To tune MySQL into a Chinese interface, it can be implemented through MySQLWorkbench or command line tools. 1) In MySQLWorkbench, open "Preferences", select the "Appearance" tab, and then select "Chinese(Simplified)" in the "Language" drop-down menu, and restart. 2) When using command line tools, set the operating system locale variables, such as using "exportLANG=zh_CN.UTF-8" on Linux or macOS, and then run the mysql client.

Frogman, a platform for comic lovers, especially those who love Taiwanese version of comics, provides a convenient online viewing channel. Frog Man brings together comic works of various themes, from passionate adventures to sweet love, from fantasy epics to urban life, everything is available to satisfy the tastes of different readers. It not only provides genuine authorized comic resources, ensuring the quality and experience of reading, but also strives to create a friendly comic community so that readers can exchange experiences, share their feelings, and explore the charm of comics together.

Logging into the OIEI Exchange computer and downloading the OIEI Exchange PC installation package is a key step to entering the world of digital currency trading. Imagine that you are sitting in front of your computer, preparing to start your digital currency trading journey, but you find that you don’t know how to log in to the OI Exchange, or you can’t find the download portal for the PC installation package. This will undoubtedly make you feel frustrated. Don’t worry, this article will answer these questions in detail, allowing you to easily get started and enjoy the digital currency market. We will guide you step by step to complete the login and download of the PC installation package of the Ouyi Exchange to ensure that you will not miss any details
