-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Description
Currently, semver.Max canonicalizes its arguments according to semver.Canonical:
https://play.golang.org/p/04IP9gNhFWH
To me, the name Max does not evoke “canonicalize”, and the action of canonicalizing is potentially fairly destructive: for example, if I have a version with a +incompatible build suffix, that version is canonical according to module.CanonicalVersion, but will not be preserved by a call to semver.Max.
@rsc points out that the canonicalization avoids ambiguity: v0.1.0+a and v0.1.0+b have the same precedence, so if we call semver.Max("v0.1.0+a", "v0.1.0+b") we would otherwise have to pick one arbitrarily, and semver.org says “Build metadata SHOULD be ignored when determining version precedence.”
Instead, I propose that Max should always return one of its arguments. Build metadata must comprise only the usual dot-separated ASCII identifiers, so if we have two versions with equal precedence it seems to me that we could break the tie using the usual rule for comparing pre-release suffixes.