SemVer
The Semver registry is designed to handle semantic versioning, offering functions to compare and manage version numbers consistently across your projects.
semver
The function creates a new semantic version object from a given version string, allowing for the structured handling and comparison of software versioning according to semantic versioning principles.
Signature
Semver(version string) (*semver.Version, error)
{{ semver "1.0.0" }} // Output: 1.0.0
{{ semver "1.0.0-alpha" }} // Output: 1.0.0-alpha
{{ (semver "2.1.0").Major }} // Output: 2
semverCompare
The function checks whether a given version string satisfies a specified semantic version constraint, ensuring that the version meets the defined requirements according to the Semantic Versioning rules.
Signature
SemverCompare(constraint, version string) (bool, error)
{{ semverCompare ">=1.0.0" "1.0.0" }} // Output: true
{{ semverCompare "1.0.0" "1.0.0" }} // Output: true
{{ semverCompare "1.0.0" "1.0.1" }} // Output: false
{{ semverCompare "~1.0.0" "1.0.0" }} // Output: true
{{ semverCompare ">1.0.0-alpha" "1.0.0-alpha.1" }} // Output: true
{{ semverCompare "1.0.0-alpha.1" "1.0.0-alpha" }} // Output: false
{{ semverCompare "1.0.0-alpha.1" "1.0.0-alpha.1" }} // Output: true
Last updated