Packages, modules and tooling · 3 MIN READ
Explain the selected version before running go get
Read minimal version selection and investigate a transitive upgrade without guessing.
A direct require is not a lock on every transitive dependency. Other requirements can raise the selected version of the same module path. Diagnose the graph first, then test the change that actually enters the build; repeatedly deleting go.sum does not explain an upgrade.
Packages and production tooling · A MAP OF THE IDEA
- Requirements
- Selected graph
- Reason for import
- Test the delta
Useful when
- Read minimal version selection and investigate a transitive upgrade without guessing.
Watch out
- The selected version for one module path must satisfy the graph’s minimum requirements. go.sum records content hashes, not a request for the newest version.
Implementation & operation cost: A graph change can raise transitive versions; review and regression-test the selected delta instead of counting edited require lines.
Observe the build list
go list -m all describes the selected module versions for this build. go mod graph shows requirement edges, while go mod why explains why a package or module is needed. These answer different questions; none proves that an upgraded API preserves your application behavior.
go list -m all
go mod graph
go mod why -m golang.org/x/text
go list -m -u allCompare the requirement edges with the selected build list. A higher minimum from another dependency can explain a version that is newer than the one your own require line originally mentioned.
Change one dependency and review the result
Choose a reviewed version rather than upgrading everything during an outage. go get changes the dependency graph; go install package@version installs a command separately. Inspect go.mod and go.sum together and run affected integration tests, including the error and timeout behavior of upgraded clients.
go get golang.org/x/text@v0.23.0
go mod tidy
git diff -- go.mod go.sum
go test ./...This is an example of a specific upgrade in a development checkout, not a recommendation that the illustrated version is current. Inspect the resulting graph and choose an appropriate supported version for your project.
Avoid false fixes
A replace can redirect source while leaving you unaware that CI builds something else. A retract signals a version that authors advise against; it does not erase an already selected dependency. Keep a minimal reproducer for an incompatible transitive update instead of treating a clean cache as a correctness test.
TAKE THIS WITH YOU
Inspect the selected graph, explain the edge that raised a version, and validate the smallest dependency change with the application behaviors it affects.
Check your understanding
Why can a transitive module be newer than your direct requirement?
Go to the source
Progress stays in this browser. No account needed.