go-version
Display Go compiler version information
TLDR
Display version
Display the Go version used to build a specific executable file
SYNOPSIS
go version
DESCRIPTION
The go version command displays the version of the Go compiler and standard library being used. This is crucial for ensuring compatibility between code and the Go environment. It's used to diagnose build issues, confirm the correct Go installation is active, and verify dependency requirements are met. The output provides information about the Go version itself (e.g., go1.21.5), the operating system the Go compiler was built for (e.g., linux), and the architecture (e.g., amd64). It is a simple command, and doesn't accept parameter. It uses information from the Go environment to determine version information.
The go version is often the first command run when troubleshooting Go projects, as an incorrect or outdated version can cause unexpected errors. It allows developers to maintain consistent development and build environments across different machines, essential for team collaboration and reproducible builds. You must have Go installed to use the command. It doesn't connect to the Internet or perform any external operations, it just shows what's already there.
CAVEATS
The go version command only reflects the version of the Go compiler and standard library installed on the system where it is executed. It does not provide information about the versions of third-party libraries used by a Go project.
It is important to distinguish between the Go toolchain version and the versions of specific packages used in a project, which must be handled by the package manager.
EXAMPLES
Display the current Go version: go version
HISTORY
The go version command has been a core part of the Go toolchain since the language's initial release. It provides a way to quickly identify the Go environment, and has remained mostly unchanged through Go's development. It's an important way to easily inspect the current version used without having to investigate the files on the file system.