How to Update Go Version: Step-by-Step Guide

Written by

in

Keeping your Go (Golang) toolchain up to date is essential for unlocking new language features, boosting compilation performance, and patching critical security vulnerabilities. Whether you are working with Go’s newest features like range-over-functions or maintaining legacy services, here is a complete guide to updating your Go version cleanly across different operating systems.


Step 1: Check Your Current Version

Before jumping into the upgrade process, verify which version of Go is currently active in your terminal. Run the following command:

go version

This will output something like go version go1.21.4 darwin/amd64. Knowing your current version helps you decide whether you need a minor patch or a major upgrade.


Step 2: Choose Your Update Method

The update process varies slightly depending on your operating system and how you originally installed Go.

Method A: macOS (Using Homebrew)

If you originally installed Go via Homebrew on macOS, updating is a single command:

  1. Update Homebrew’s repository data:
    brew update
    
  2. Upgrade the Go package:
    brew upgrade go
    

Method B: Linux (Official Tarball)

Linux distributions often package older versions of Go in their default repositories. For the most up-to-date release, manual installation via the official tarball is recommended:

  1. Remove the existing Go installation (typically located at /usr/local/go):
    sudo rm -rf /usr/local/go
    
  2. Download the latest tarball from the official Go website (replace 1.x.x with the target version

Comments

Leave a Reply

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