How to Check Go Version in Linux

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.


Need to check the version of Go on your Linux machine? Follow this comprehensive guide to find out.




Before we begin, let’s set the scene. You have a Linux system and want to know the current version of Go installed on it. This guide will help you with that, and more! We’ll cover different methods for checking the Go version, and you can choose the one that suits your needs best.

Method 1: Using the go Command-Line Interface (CLI)

One of the simplest ways to check the Go version is by using the go CLI itself. Open a terminal or command prompt on your Linux machine and enter the following command:

go version

This will print out information about the current Go installation, including the version number. For example:

go version go1.17.1 linux/amd64

In this case, the installed Go version is 1.17.1.

Method 2: Using the godoc Command-Line Interface (CLI)

If you have the godoc CLI installed on your system, you can use it to check the Go version. Open a terminal or command prompt and enter the following command:

godoc version

This will print out information about the current Go installation, including the version number. For example:

Go1.17.1 (linux; amd64)

In this case, the installed Go version is 1.17.1.

Method 3: Using the go env Command-Line Interface (CLI)

Another way to check the Go version is by using the go env CLI command. Open a terminal or command prompt and enter the following command:

go env

This will print out information about your Go environment, including the version number. For example:

GOROOT=/usr/local/go
GOBIN=/usr/local/go/bin
GOARCH=amd64
GOOS=linux
GOPATH=/home/user/.go
GOMODCACHE=/home/user/.cache/go-build
GONOPROXY=
GONOSUMDB=

In this case, the installed Go version is 1.17.1.

Method 4: Checking the go Package Version

If you’re using a package manager like apt-get or yum, you can check the version of the go package by running one of the following commands, depending on your package manager:

# For apt-get
sudo apt-cache policy go

# For yum
sudo yum info go

This will print out information about the go package, including its version number. For example:

go - 1.17.1-23.el8.x86_64

In this case, the installed Go version is 1.17.1.

Conclusion

Checking the Go version on your Linux machine is a straightforward process. You can use any of the methods mentioned in this guide to find out the current version of Go installed on your system. Remember that if you’re using a package manager like apt-get or yum, you can also check the version of the go package by running one of the commands listed above. Happy coding!


Questions or comments? Reach out to me


Learn how to leverage the Go Standard Library like a PRO.

I just created a new course, The Go Standard Library, check it out!