go_module_resolution
Resolves native Go requirements as graph actions, with optional guarded update
proposals. Use go_workspace when you also
want package, command and test targets.
Struo reads go.mod, go.sum and an optional go.work with its member manifests
and checksums. Starlark owns minimum version selection, graph pruning,
exclusions and replacement selection. Generated
go_module_metadata actions acquire
individual exact-version manifests or read local replacements. The resolver
publishes a go_resolved_graph only
after selection converges. Native Go authenticates exact acquisitions; it does
not select the graph.
Example#
[[target]]
name = "resolve"
kind = "go_module_resolution"
srcs = ["go.mod", "go.sum"]
[target.attrs]
propose_updates = true
[target.attrs.upgrade_versions]
"example.com/library" = "v1.2.3"The requirement must already exist in go.mod. Building resolve writes
proposals, not source files. Review the generated proposed directory and use
the explicit source transaction
to apply the changes.
Attributes#
| Attribute | Type | Default | Description |
|---|---|---|---|
manifest | string | go.mod | Package-relative module manifest |
workspace_file | string | unset | Package-relative go.work; member manifests and checksums participate in resolution |
go | string | discovered Go command | Command used for authenticated exact-version acquisition |
propose_updates | bool | false | Emit native manifest/checksum proposals and an explicitly applicable guarded transaction |
operation | string | reconcile | Reconcile declared requirements, or use tidy to derive standalone Go 1.18+ requirements from known package providers |
upgrade_versions | map<string,string> | {} | Canonical exact upgrades of already declared standalone requirements; requires propose_updates = true |
Include native manifests and checksum files in srcs; workspace members can
use globs such as **/go.mod and **/go.sum. Missing optional checksum files
are observed as absent. The generated deps role accepts go_resolution.
The target emits go_resolution and exposes build without an output group.
Its generated ready target owns the output files.
Update limits#
Exact requests reject undeclared modules, explicit downgrades, noncanonical or path-major-incompatible versions, version queries and workspace operations. The settled graph must select each requested version exactly. Legacy unpruned graphs retain their original selected versions as floors before applying upgrades; superseded requirements of the upgraded version do not become new constraints.
The default operation preserves existing comments, directives and checksum
history while reconciling declared requirements. With operation = "tidy",
Struo scans main packages under native all-build-tags rules, follows ordinary
and test imports, removes unused requirements, recomputes directness and prunes
unused sums. The transaction guards source contents and directory membership,
so adding a new source file invalidates an outstanding proposal. Include source
globs such as **/*.go in srcs when requesting this operation.
Tidy currently requires a standalone Go 1.18+ module with all import providers
already represented by its selected requirements or replacements. It rejects
workspace mode, simultaneous exact upgrades, tool and ignore directives,
legacy compatibility graphs and missing providers rather than delegating to a
native solver. Full go get, version discovery, reverse-dependency downgrades
and import-derived go work sync remain unsupported. Ambiguous lookups fail;
Struo does not yet promote test-only roots to disambiguate a graph after pruning.
See the
Go workspace limits for
acquisition and configuration boundaries.