How to Check Your Go Version in Linux and macOS

Hey! If you love Go and building Go apps as much as I do, let's connect on Twitter or LinkedIn. I talk about this stuff all the time!

Want to learn how to build better Go applications faster and easier? You can.

Check out my course on the Go Standard Library. You can check it out now for free.


When working with Go, knowing the version of the language is essential. Different versions of Go may have different features and bugs that can impact the performance of your code. In this article, we will explain how to check the version of Go on Linux and macOS.

Method 1: Using the go command-line tool

The simplest way to check the Go version is by using the go command-line tool. To do this, open your terminal or command prompt and type go version. This will display the version of Go that is currently installed on your system. For example:

$ go version
go version go1.16.7 linux/amd64

This output shows that we are using Go version 1.16.7 on a Linux/x86_64 platform.

Method 2: Checking the environment variable GOROOT

Alternatively, you can check the value of the GOROOT environment variable to see what version of Go is installed. To do this, open your terminal or command prompt and type echo $GOROOT. This will display the path to the root directory of the Go installation on your system. For example:

$ echo $GOROOT
/usr/local/go

This output shows that the GOROOT environment variable is set to /usr/local/go, which means that we are using Go version 1.16.7.

Method 3: Checking the system information

Another way to check the Go version on Linux and macOS is by checking the system information. To do this, open your terminal or command prompt and type uname -a. This will display detailed information about your operating system, including the version of Go that is installed. For example:

$ uname -a
Linux 5.10.0-9-amd64 #1 SMP Debian 5.10.28-2 (2022-03-07) x86_64 GNU/Linux

This output shows that we are using Linux version 5.10.0-9, which is a fairly recent version of the operating system. This information can help you determine whether your Go installation is compatible with the system or not.

In conclusion, knowing the version of Go on Linux and macOS is crucial for ensuring compatibility with different Go projects. You can check the version by using the go command-line tool, checking the value of the GOROOT environment variable, or checking the system information. By doing so, you can ensure that your Go code runs smoothly on any system it is intended to be run on.



Stay up to date on the latest in Coding for AI and Data Science

Intuit Mailchimp