go Operations¶
Manage Go (Golang) binary packages installed via go install.
Facts used in these operations: go.GoPackages.
go.packages¶
Add/remove/update Go binary packages installed via go install.
go.packages(
packages: 'str | list[str] | None' = None,
present: 'bool' = True,
latest: 'bool' = False,
**kwargs,
)
- packages: list of packages to ensure
- present: whether the packages should be installed
- latest: whether to upgrade packages without a specified version
Note:
latest=True is not idempotent offline: without a version to compare
against, an installed unversioned package always re-runs go install
and reports as changed every run (same as pip.packages with latest).
Versions:
Package versions can be pinned like go: <pkg>@<version>. Packages
without a pinned version (or with the special @latest suffix) are
installed at the latest available version.
Example:
from pyinfra.operations import go
# Note: Assumes that 'go' is installed.
go.packages(
name="Install staticcheck",
packages=["honnef.co/go/tools/cmd/staticcheck"],
)
Global arguments
This operation also inherits all global arguments.