// cmpVersion implements the comparison for versions in the module loader. // // It is consistent with gover.ModCompare except that as a special case, // the version "" is considered higher than all other versions. // The main module (also known as the target) has no version and must be chosen // over other versions of the same module in the module dependency graph. func cmpVersion(p string, v1, v2 string) int { … } type mvsReqs … func (r *mvsReqs) Required(mod module.Version) ([]module.Version, error) { … } // Max returns the maximum of v1 and v2 according to gover.ModCompare. // // As a special case, the version "" is considered higher than all other // versions. The main module (also known as the target) has no version and must // be chosen over other versions of the same module in the module dependency // graph. func (*mvsReqs) Max(p, v1, v2 string) string { … } // Upgrade is a no-op, here to implement mvs.Reqs. // The upgrade logic for go get -u is in ../modget/get.go. func (*mvsReqs) Upgrade(m module.Version) (module.Version, error) { … } func versions(ctx context.Context, path string, allowed AllowedFunc) (versions []string, origin *codehost.Origin, err error) { … } // previousVersion returns the tagged version of m.Path immediately prior to // m.Version, or version "none" if no prior version is tagged. // // Since the version of a main module is not found in the version list, // it has no previous version. func previousVersion(ctx context.Context, m module.Version) (module.Version, error) { … } func (*mvsReqs) Previous(m module.Version) (module.Version, error) { … }