Skip to content

cmd/go: v1.2 module query matches pre-v1.2 versions #31972

@rsc

Description

@rsc

Version queries like @v1.2 are handled by this code in cmd/go/internal/modload/query.go:

// matchSemverPrefix reports whether the shortened semantic version p
// matches the full-width (non-shortened) semantic version v.
func matchSemverPrefix(p, v string) bool {
	return len(v) > len(p) && v[len(p)] == '.' && v[:len(p)] == p
}

matchSemverPrefix("v1.2", "v1.2.0-prerelease") is true but probably should be false, because semver.Compare("v1.2", "v1.2.0-prerelease") < 0.

/cc @jayconrod @bcmills

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions