← 返回命令列表

Linux command

go-get 命令

文本

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

常用示例

Download package

go get [github.com/pkg/errors]

Download specific version

go get [github.com/pkg/errors@v0.9.1]

Update package

go get -u [package]

Download all dependencies

go get ./...

Install binary

go install [github.com/user/tool@latest]

说明

go get downloads and installs packages and dependencies. In module mode, it updates go.mod and go.sum files to track dependencies. For installing tool binaries, use go install instead. The command resolves versions from module proxies, supporting semantic versioning. It can target specific versions, branches, or commits.

参数

-u
Update to latest version.
-d
Download only, don't install.
-t
Include test dependencies.
@ _VERSION_
Specify version.
--help
Display help information.

FAQ

What is the go-get command used for?

go get downloads and installs packages and dependencies. In module mode, it updates go.mod and go.sum files to track dependencies. For installing tool binaries, use go install instead. The command resolves versions from module proxies, supporting semantic versioning. It can target specific versions, branches, or commits.

How do I run a basic go-get example?

Run `go get [github.com/pkg/errors]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -u do in go-get?

Update to latest version.