Find out the version of Go a Binary was built with?

Use runtime.Version() at runtime to figure out what version of Go your binary was built with:

func Version() string

Version returns the Go tree's version string. It is either a sequence number or, when possible, a release tag like "release.2010-03-04". A trailing + indicates that the tree had local modifications at the time of the build.

For existing binaries, use the go version command:

usage: go version [-m] [-v] [file ...]

Version prints the build information for Go executables.

Go version reports the Go version used to build each of the named executable files.

If no files are named on the command line, go version prints its own version information.

If a directory is named, go version walks that directory, recursively, looking for recognized Go binaries and reporting their versions. By default, go version does not report unrecognized files found during a directory scan. The -v flag causes it to report unrecognized files.

The -m flag causes go version to print each executable's embedded module version information, when available. In the output, the module information consists of multiple lines following the version line, each indented by a leading tab character.


Use go version <path>.

$ go version /usr/bin/syncthing
/usr/bin/syncthing: go1.13.10

$ go version
go version go1.14.3 linux/amd64

The following command should do it:

# strings binary_path | grep 'go1\.' 
go1.5.3

Tags:

Go