DEV Community

Cover image for What Are the Steps to Install Golang on Macos in 2025?
Negrito 👌
Negrito 👌

Posted on

What Are the Steps to Install Golang on Macos in 2025?

Golang, also known as Go, is a statically typed, compiled language designed with simplicity and performance in mind. If you're developing on macOS, you'll need to install Golang to take advantage of its speed and efficiency for your projects. In this article, we will walk you through the steps to install Golang on macOS in 2025.

Follow these steps for a smooth installation process and ensure you're ready to start developing in Golang!

Step 1: Update Your System

Before installing any new software, it's a good practice to ensure your system is up to date. Open your Terminal and run the following command to download and install the latest macOS updates:

softwareupdate --install --all
Enter fullscreen mode Exit fullscreen mode

Step 2: Download Golang

Visit the official Golang download page to get the latest version compatible with macOS. As of 2025, you should download the .pkg installer for macOS.

Step 3: Install Golang

  1. Locate the downloaded .pkg file in your Downloads folder.
  2. Double-click the .pkg file to open the Installer.
  3. Follow the on-screen instructions to complete the installation. By default, Golang will be installed in /usr/local/go.

Step 4: Set Up Your Go Environment

After installation, you'll need to set up your Go environment. Add the Go binary to your system's PATH for convenient access:

  1. Open your Terminal.
  2. Edit your shell profile file (.zshrc, .bash_profile, or .bashrc, depending on your shell).
  3. Add the following lines to the file:

export PATH=$PATH:/usr/local/go/bin
Enter fullscreen mode Exit fullscreen mode
  1. Save the file and apply the changes by running:
source ~/.zshrc   # or ~/.bash_profile or ~/.bashrc
Enter fullscreen mode Exit fullscreen mode

Step 5: Verify the Installation

To confirm that Golang has been installed correctly, run the following command in your Terminal:

go version
Enter fullscreen mode Exit fullscreen mode

This command should return the installed version of Golang, indicating that the installation was successful.

Step 6: Test Your Go Installation

Create a simple Go program to test the setup:

  1. Create a new directory for your Go workspace, and navigate into it:
mkdir ~/go-workspace
cd ~/go-workspace
Enter fullscreen mode Exit fullscreen mode
  1. Create a new Go file named hello.go:
touch hello.go
Enter fullscreen mode Exit fullscreen mode
  1. Open hello.go in your preferred text editor and add the following code:
package main

import "fmt"

func main() {
    fmt.Println("Hello, Go!")
}
Enter fullscreen mode Exit fullscreen mode
  1. Save the file and execute it using:
go run hello.go
Enter fullscreen mode Exit fullscreen mode

You should see "Hello, Go!" printed in your Terminal, indicating that your Go installation is working correctly.

Conclusion

Following these steps, you should be able to install Golang on your macOS in 2025 successfully. Whether you're building web applications or developing system-level software, Golang provides the performance and simplicity developers need.

If you're interested in installing Golang on other platforms, check out these resources:

By following these links, you can ensure seamless Golang installations on various operating systems.

Top comments (0)