Dependency Resolution
A module names itself and its requirements in go.mod, and the go command resolves them into one build list — the lowest version that satisfies everyone, with each major version at its own import path.
part ofGo (Golang)overview, primer and where to startread it →on this pageshowhide
explore
- Vendored Dependencies5 questions
- go.mod and the Module Graph5 questions
- Semantic Import Versioning (v2+)5 questions
- Tagging and Publishing5 questions
- Minimal Version Selection5 questions
- replace, exclude and retract5 questions
- Module Proxy, go.sum and Private Modules5 questions
- Workspaces (go.work)4 questions
- Upgrading and Graph Pruning4 questions
questions
page 2 of 2How do you decide between proxy.golang.org and an internal Go module mirror for a build fleet?
basics
~20 sDecide on egress policy, availability and ownership. The public mirror is free, durable and highly available but puts every build on the public internet; an internal mirror buys allowlisting and one credential boundary, and becomes a company-wide single point of failure.
How do you decide whether an internal Go package should become a published module other teams depend on?
basics
~20 sPublishing is a support commitment, not a packaging step. Decide on who else genuinely needs it, whether you will honour a stable import path for years, and whether keeping it internal or copying the code is cheaper.
As a Go library owner, how do you decide between cutting a /v2 module path and keeping a change inside v1?
basics
~20 sWeigh what a /v2 costs everyone else. Because consumers must rewrite import paths by hand and no upgrade command crosses a major, a v2 reaches nobody automatically and you maintain two trees. Cut one only when the break cannot be made additive.
How do you decide whether a shared Go repo commits vendor/, given every dependency bump then lands in review?
basics
~20 sDecide by asking who bears each cost. Committing the vendor directory buys builds that need no network and puts every dependency change into code review, at the price of huge diffs, merge conflicts and a second tree to keep in sync with go.mod.
When should your team commit go.work, and when should the repo be a single module instead?
basics
~20 sCommit go.work only when every directory it uses lives in this repository and every developer wants that same set, and only as a convenience no pipeline depends on. Default to one module unless parts genuinely need independent release lines.
What does an `exclude` directive in go.mod do when something in the module graph requires that exact version?
basics
~20 sAn exclude line in the main module's go.mod makes the go command act as if that version of that module does not exist. Requirements on it move up to the next higher available version, and the build fails if none exists.
In a repo whose root is one module and whose ./cli directory is another, how do you tag the cli module?
basics
~10 sPrefix the Git tag with the module's directory path relative to the repository root: cli/v1.2.0 publishes the module whose go.mod sits in ./cli. A plain v1.2.0 tag publishes only the root module.
How do you lay out a Go repository so it can publish both v1 and v2 of the same module?
basics
~20 sTwo layouts work. Put v2 in a v2/ subdirectory with its own go.mod whose module line ends in /v2, or keep it on a branch whose root go.mod ends in /v2. Either way the module's own imports must gain /v2.
In a Go workspace, what does `go work sync` change in each module's go.mod?
basics
~20 sgo work sync computes one dependency version list for the whole workspace, then writes those selected versions back into the go.mod of each module the workspace uses. It raises requirements a module already declares; it does not add new ones.
Your CI's installed Go is older than a go.mod `go` line requires — what does the go command do?
basics
~20 sBy default the go command does not fail: it downloads and re-executes with a newer Go toolchain that satisfies the go.mod requirement. Setting GOTOOLCHAIN=local disables that, and the command then refuses with an error naming the required and running versions.
What is in the Go module cache (GOMODCACHE), and when is go clean -modcache the right fix?
basics
~20 sGOMODCACHE holds every downloaded module version, extracted read-only, plus the raw files as fetched. Clearing it forces a fresh download: the right fix for a corrupted local cache, and no fix for a checksum mismatch.
In Go, what happens to the rest of the module graph when you downgrade one dependency to an older version?
basics
~20 sOther modules move too. Because a selected version is the maximum of stated minimums, the go command must also downgrade or drop any module whose own go.mod requires a higher version of your target, and it never upgrades anything to compensate.
For 40 Go services on an automated bump pipeline, how do you set upgrade cadence and who may force a transitive bump?
basics
~20 sRun patch-only upgrades on a frequent schedule so diffs stay reviewable, take minor upgrades deliberately per service before a release, and let any engineer pin a transitive module upward under an advisory, provided the pin is recorded and revisited later.
showing 31–43 of 43