Documentation ¶
Overview ¶
Package module defines the module.Version type along with support code.
Index ¶
- func CanonicalVersion(v string) string
- func Check(path, version string) error
- func CheckFilePath(path string) error
- func CheckImportPath(path string) error
- func CheckPath(path string) error
- func DecodePath(encoding string) (path string, err error)
- func DecodeVersion(encoding string) (v string, err error)
- func EncodePath(path string) (encoding string, err error)
- func EncodeVersion(v string) (encoding string, err error)
- func MatchPathMajor(v, pathMajor string) bool
- func Sort(list []Version)
- func SplitPathVersion(path string) (prefix, pathMajor string, ok bool)
- type Version
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanonicalVersion ¶
CanonicalVersion returns the canonical form of the version string v. It is the same as semver.Canonical(v) except that it preserves the special build suffix "+incompatible".
func Check ¶
Check checks that a given module path, version pair is valid. In addition to the path being a valid module path and the version being a valid semantic version, the two must correspond. For example, the path "yaml/v2" only corresponds to semantic versions beginning with "v2.".
func CheckFilePath ¶
CheckFilePath checks whether a slash-separated file path is valid.
func CheckImportPath ¶
CheckImportPath checks that an import path is valid.
func DecodePath ¶
DecodePath returns the module path of the given safe encoding. It fails if the encoding is invalid or encodes an invalid path.
func DecodeVersion ¶
DecodeVersion returns the version string for the given safe encoding. It fails if the encoding is invalid or encodes an invalid version. Versions are allowed to be in non-semver form but must be valid file names and not contain exclamation marks.
func EncodePath ¶
EncodePath returns the safe encoding of the given module path. It fails if the module path is invalid.
func EncodeVersion ¶
EncodeVersion returns the safe encoding of the given module version. Versions are allowed to be in non-semver form but must be valid file names and not contain exclamation marks.
func MatchPathMajor ¶
MatchPathMajor reports whether the semantic version v matches the path major version pathMajor.
func Sort ¶
func Sort(list []Version)
Sort sorts the list by Path, breaking ties by comparing Versions.
func SplitPathVersion ¶
SplitPathVersion returns prefix and major version such that prefix+pathMajor == path and version is either empty or "/vN" for N >= 2. As a special case, gopkg.in paths are recognized directly; they require ".vN" instead of "/vN", and for all N, not just N >= 2.
Types ¶
type Version ¶
type Version struct { Path string // Version is usually a semantic version in canonical form. // There are two exceptions to this general rule. // First, the top-level target of a build has no specific version // and uses Version = "". // Second, during MVS calculations the version "none" is used // to represent the decision to take no version of a given module. Version string `json:",omitempty"` }
A Version is defined by a module path and version pair.