go_run
go_run invokes go run <package> <args...> for a local package or go run <package>@<version> <args...> for a remote package with the managed SDK. Local package paths are absolute, ., .., or start with ./ or ../; Windows also accepts equivalent backslash forms. Local packages must omit version, while remote packages require it. The command runs from the project root during xx run; pass the returned dependency to deps when another task must wait for it.
Arguments
| Argument | Required | Description |
|---|---|---|
package | Yes | Non-empty local or remote Go package path without an @version suffix. |
version | For remote packages | Non-empty Go version query appended to a remote package path. Must be omitted for local packages. |
args | No | String arguments passed to the Go command. Defaults to []. |
deps | No | Dependencies activated before running the command, in list order. Defaults to []. |
Examples
Run a local program
load("@[email protected]", "go_run")
go_run(".")
Run a tool
load("@[email protected]", "go_run")
go_run(
package="codeberg.org/tsukinoko-kun/doctopus",
version="latest",
args=["build"],
)
Run a pinned generator with configuration
load("@[email protected]", "go_run")
load("@os@1", "env_set")
go_run(
package="github.com/sqlc-dev/sqlc/cmd/sqlc",
version="v1.29.0",
args=["generate"],
deps=[env_set("GOWORK", "off")],
)