go version: Usage, Options & Common CI Errors
Report the Go toolchain (or a binary’s) version.
go version prints the installed Go toolchain version. Given a binary or directory it prints the Go version each binary was built with, and with -m the embedded module build info.
What it does
With no argument, prints the running toolchain (e.g. go version go1.22.5 linux/amd64). With file arguments, reports the build version of each Go binary; -m adds the module dependency list baked into the binary.
Common usage
go version # toolchain version
go version ./bin/app # version a binary was built with
go version -m ./bin/app # embedded module build infoCommon CI error: toolchain mismatch
A build fails or behaves differently because the runner’s go version differs from what the project expects - or go.mod’s go/toolchain directive triggers an automatic toolchain download you did not anticipate. Fix: pin the version in setup-go (go-version: ‧1.22.x’), assert it in CI with go version, and keep the go directive in go.mod aligned with the installed toolchain.
Options
| Form | Effect |
|---|---|
| go version | Print toolchain version |
| go version <file> | Version of a built binary |
| -m | Show embedded module info |