package version
Import Path
golang.org/x/pkgsite/internal/version (on go.dev)
Dependency Relation
imports 4 packages, and imported by 6 packages
Involved Source Files
Package version handles version types.
Package-Level Type Names (only one, which is exported)
Type defines the version types a module can have.
This must be kept in sync with the 'version_type' database enum.
( T) String() string
T : expvar.Var
T : fmt.Stringer
T : context.stringer
T : runtime.stringer
func ParseType(version string) (Type, error)
func golang.org/x/pkgsite/internal/postgres.getPathVersions(ctx context.Context, db *postgres.DB, path string, versionTypes ...Type) (_ []*internal.ModuleInfo, err error)
func golang.org/x/pkgsite/internal/postgres.versionTypeExpr(vts []Type) string
const TypePrerelease
const TypePseudo
const TypeRelease
Package-Level Functions (total 9, in which 8 are exported)
ForSorting returns a string that encodes version, so that comparing two such
strings follows SemVer precedence, https://semver.org clause 11. It assumes
version is valid. The returned string ends in '~' if and only if the version
does not have a prerelease.
For examples, see TestForSorting.
IsIncompatible reports whether a valid version v is an incompatible version.
IsPseudo reports whether a valid version v is a pseudo-version.
Modified from src/cmd/go/internal/modfetch.
Later reports whether v1 is later than v2, using semver but preferring
release versions to pre-release versions, and both to pseudo-versions.
Latest finds the latest version of a module using the same algorithm as the
Go command. It prefers tagged release versions to tagged pre-release
versions, and both of those to pseudo-versions. If versions is empty, Latest
returns the empty string.
hasGoMod should report whether the version it is given has a go.mod file.
Latest returns the latest incompatible version only if the latest compatible
version does not have a go.mod file.
The meaning of latest is defined at
https://golang.org/ref/mod#version-queries. That definition does not deal
with retractions, or with a subtlety involving incompatible versions. The
actual definition is embodied in the go command's queryMatcher.filterVersions
method. This function is a re-implementation and specialization of that
method at Go version 1.16
(https://go.googlesource.com/go/+/refs/tags/go1.16/src/cmd/go/internal/modload/query.go#441).
LatestOf returns the latest version of a module from a list of versions, using
the go command's definition of latest: semver is observed, except that
release versions are preferred to prerelease, and both are preferred to pseudo-versions.
If versions is empty, the empty string is returned.
ParseType returns the Type of a given a version.
RemoveIf returns a copy of s that omits all values for which f returns true.
Package-Level Variables (only one, which is unexported)
Package-Level Constants (total 3, all are exported)
TypePrerelease is a version with a prerelease.
TypePseudo appears to have a prerelease of the
form <commit date>-<commit hash>.
TypeRelease is a normal release.
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |