Documentation
¶
Overview ¶
Package version provides version comparison and filtering utilities.
Index ¶
- Constants
- func Compare(v1, v2 string) (int, error)
- func CompareVersions(v1, v2 string) (int, error)
- func ContainsVersion(versions []string, target string) bool
- func FindMaxVersion(versions []string) (string, error)
- func IsDowngrade(currentVersion, candidateVersion string) (bool, error)
- func MatchesVersionPattern(pattern, target string) bool
- func ParseVersion(version string) (*semver.Version, error)
- type VersionInfo
Constants ¶
const (
// Latest represents the special "latest" version tag.
Latest = "latest"
)
Variables ¶
This section is empty.
Functions ¶
func Compare ¶
Compare compares two version strings using semantic versioning. Returns:
-1 if v1 < v2 0 if v1 == v2 1 if v1 > v2
func CompareVersions ¶
CompareVersions compares two version strings. Returns:
- -1 if v1 < v2
- 0 if v1 == v2
- 1 if v1 > v2
- error if either version is invalid
func ContainsVersion ¶
ContainsVersion checks if a version string is in the list. Supports both exact matches and glob patterns (e.g., "1.21.x").
func FindMaxVersion ¶
FindMaxVersion finds the maximum version from a list of version strings. Returns empty string if the list is empty or all versions are invalid.
func IsDowngrade ¶
IsDowngrade checks if changing from currentVersion to candidateVersion would be a downgrade.
func MatchesVersionPattern ¶
MatchesVersionPattern checks if a target version matches a glob pattern. Supports patterns like "1.21.x" which matches any version starting with "1.21.".
Types ¶
type VersionInfo ¶
type VersionInfo struct {
// Version is the version string.
Version string
// ReleaseDate is when this version was released.
ReleaseDate time.Time
}
VersionInfo contains metadata about a specific version.
func FilterByUpdateDelay ¶
func FilterByUpdateDelay(versions []VersionInfo, delay time.Duration) []VersionInfo
FilterByUpdateDelay filters versions based on release date and update delay. Only versions released before (now - delay) are returned. If delay is zero, all versions are returned.