skip to content

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 pageshow

explore

questions

page 2 of 2

How do you decide between proxy.golang.org and an internal Go module mirror for a build fleet?

level: principalimportance: should knowfreq 38%

basics

~20 s

Decide 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.

open as a page

How do you decide whether an internal Go package should become a published module other teams depend on?

level: principalimportance: should knowfreq 35%

basics

~20 s

Publishing 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.

open as a page

As a Go library owner, how do you decide between cutting a /v2 module path and keeping a change inside v1?

level: principalimportance: should knowfreq 30%

basics

~20 s

Weigh 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.

open as a page

How do you decide whether a shared Go repo commits vendor/, given every dependency bump then lands in review?

level: principalimportance: should knowfreq 28%

basics

~20 s

Decide 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.

open as a page

When should your team commit go.work, and when should the repo be a single module instead?

level: principalimportance: should knowfreq 32%

basics

~20 s

Commit 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.

open as a page

What does an `exclude` directive in go.mod do when something in the module graph requires that exact version?

level: middleimportance: nice to knowfreq 26%

basics

~20 s

An 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.

open as a page

In a repo whose root is one module and whose ./cli directory is another, how do you tag the cli module?

level: middleimportance: nice to knowfreq 30%

basics

~10 s

Prefix 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.

open as a page

How do you lay out a Go repository so it can publish both v1 and v2 of the same module?

level: middleimportance: nice to knowfreq 35%

basics

~20 s

Two 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.

open as a page

In a Go workspace, what does `go work sync` change in each module's go.mod?

level: middleimportance: nice to knowfreq 25%

basics

~20 s

go 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.

open as a page

Your CI's installed Go is older than a go.mod `go` line requires — what does the go command do?

level: seniorimportance: nice to knowfreq 28%

basics

~20 s

By 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.

open as a page

What is in the Go module cache (GOMODCACHE), and when is go clean -modcache the right fix?

level: seniorimportance: nice to knowfreq 34%

basics

~20 s

GOMODCACHE 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.

open as a page

In Go, what happens to the rest of the module graph when you downgrade one dependency to an older version?

level: seniorimportance: nice to knowfreq 26%

basics

~20 s

Other 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.

open as a page

For 40 Go services on an automated bump pipeline, how do you set upgrade cadence and who may force a transitive bump?

level: principalimportance: nice to knowfreq 30%

basics

~20 s

Run 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.

open as a page

showing 31–43 of 43