go_install
go_install runs go install <package>@<version> with the managed SDK. Installation runs during xx run. Pass the returned dependency to a command's deps to make the installed command available in its PATH.
Installed commands are available only during the current xx run. Different packages and versions can coexist. Declaring the same SDK, package, and version more than once in one run 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", "os_run")
doctopus = go_install(
package="codeberg.org/tsukinoko-kun/doctopus",
version="latest",
)
os_run(("doctopus", "build"), deps=[doctopus])
Install a pinned tool with environment configuration
load("@[email protected]", "go_install")
load("@os@1", "env_set", "os_run")
stringer = go_install(
package="golang.org/x/tools/cmd/stringer",
version="v0.36.0",
deps=[env_set("GOPROXY", "https://proxy.golang.org,direct")],
)
os_run(("stringer", "-type=Status"), deps=[stringer])