type Reqs … type UpgradeReqs … type DowngradeReqs … // BuildList returns the build list for the target module. // // target is the root vertex of a module requirement graph. For cmd/go, this is // typically the main module, but note that this algorithm is not intended to // be Go-specific: module paths and versions are treated as opaque values. // // reqs describes the module requirement graph and provides an opaque method // for comparing versions. // // BuildList traverses the graph and returns a list containing the highest // version for each visited module. The first element of the returned list is // target itself; reqs.Max requires target.Version to compare higher than all // other versions, so no other version can be selected. The remaining elements // of the list are sorted by path. // // See https://research.swtch.com/vgo-mvs for details. func BuildList(targets []module.Version, reqs Reqs) ([]module.Version, error) { … } func buildList(targets []module.Version, reqs Reqs, upgrade func(module.Version) (module.Version, error)) ([]module.Version, error) { … } // Req returns the minimal requirement list for the target module, // with the constraint that all module paths listed in base must // appear in the returned list. func Req(mainModule module.Version, base []string, reqs Reqs) ([]module.Version, error) { … } // UpgradeAll returns a build list for the target module // in which every module is upgraded to its latest version. func UpgradeAll(target module.Version, reqs UpgradeReqs) ([]module.Version, error) { … } // Upgrade returns a build list for the target module // in which the given additional modules are upgraded. func Upgrade(target module.Version, reqs UpgradeReqs, upgrade ...module.Version) ([]module.Version, error) { … } // Downgrade returns a build list for the target module // in which the given additional modules are downgraded, // potentially overriding the requirements of the target. // // The versions to be downgraded may be unreachable from reqs.Latest and // reqs.Previous, but the methods of reqs must otherwise handle such versions // correctly. func Downgrade(target module.Version, reqs DowngradeReqs, downgrade ...module.Version) ([]module.Version, error) { … } type override … func (r *override) Required(m module.Version) ([]module.Version, error) { … }