go_install
go_install runs go install <package>@<version> with the managed SDK. It registers installation as a root task and returns a dependency that adds the installed command to PATH for downstream tasks.
Installed commands live in a command-scoped temporary directory and are removed after the xx run invocation. Each package and version gets a separate directory, preventing commands from replacing one another. Declaring the same SDK, package, and version more than once in one invocation fails with an output conflict.
Arguments
| Argument | Required | Description |
|---|---|---|
package | Yes | Non-empty Go package path without an @version suffix. |
version | Yes | Non-empty Go version query, such as a semantic version, revision, branch, or latest. |
deps | No | Dependencies activated before installation, in list order. Defaults to []. |
Examples
Install and run a command
load("@[email protected]", "go_install")
load("@os@1", "run")
doctopus = go_install(
package="codeberg.org/tsukinoko-kun/doctopus",
version="latest",
)
run(("doctopus", "build"), deps=[doctopus])
Install a pinned tool with environment configuration
load("@[email protected]", "go_install")
load("@os@1", "env_set", "run")
stringer = go_install(
package="golang.org/x/tools/cmd/stringer",
version="v0.36.0",
deps=[env_set("GOPROXY", "https://proxy.golang.org,direct")],
)
run(("stringer", "-type=Status"), deps=[stringer])