← 返回命令列表

Linux command

go-version 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Show Go version

go version

Show binary's Go version

go version [binary]

Show version of all binaries

go version -m [binary]

说明

go version prints the Go runtime version of the toolchain when invoked without arguments. When given file arguments — executables or directories of executables — it reports the Go version each binary was built with, and with -m also dumps the build-time module dependency graph (`go.mod`-equivalent info) embedded in the binary. Directory arguments are walked recursively; non-Go executables are skipped silently unless -v is given.

参数

-m
Print each executable's embedded module version information (added in Go 1.13).
-v
Report unrecognized files (otherwise non-Go files are silently skipped when scanning a directory).
--help
Display help information.

FAQ

What is the go-version command used for?

go version prints the Go runtime version of the toolchain when invoked without arguments. When given file arguments — executables or directories of executables — it reports the Go version each binary was built with, and with -m also dumps the build-time module dependency graph (`go.mod`-equivalent info) embedded in the binary. Directory arguments are walked recursively; non-Go executables are skipped silently unless -v is given.

How do I run a basic go-version example?

Run `go version` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -m do in go-version?

Print each executable's embedded module version information (added in Go 1.13).