How to Check Version of Golang: The Easiest Way

A software version is a number or identifier representing a program’s current state. Software versions are used to track the evolution of a program over time and to identify and distinguish different versions of the same program.

For example, a software program might have the following version numbers:

  1. 1.0.0: The initial release of the program.
  2. 1.1.0: A minor release that adds new features.
  3. 1.1.1: A patch release that fixes bugs and issues.
  4. 2.0.0: A major release that adds significant new features and changes.

Every programming language provides a way to see its version via command and Go is no different.

Golang check version

To check the Golang version, use the go version command. This command prints the version of Go currently installed on your system.

$ go version

go version go1.19.3 darwin/arm64

In this example, the “go version” command prints the current version installed on the system. The output shows that the installed version is go1.19.3 darwin/arm64. I am using Macbook M1 Air, so my OS is 64-bit.

go help version

The `go help version` command prints detailed information about the version of Go that you have installed on your system. It provides information about the Go version, the compiler and linker versions, and the target operating system and architecture.

Check what version of Go a binary was built with

To get the version of Go in which the given application was built, use the go version command, passing the path to the binary as an argument.

go version <path/to/the/binary>

To get the version of the Go binary was built with, use go version “your-app-name” where “your-app-name” is the name of your built application.

Let’s make a simple “go-app” application and save it as a main.go file:

package main

import "fmt"

func main() {
  fmt.Println("GoApp")
}

Then build the application using the command:

go build -o go-app

Now, check what version of Go in which the go-app application was built with:

go version go-app

In the output, you should see the application name and version:

go-app: go1.19.3

And we get the version of Go that the application was built on.

Conclusion

The easiest way to check the version of Golang is to use the “go version” command.

That’s it.

Leave a Comment