version

package
v0.0.0-...-c2f0c6c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 4 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bump

func Bump(version string, releaseType ReleaseType) (string, error)

Bump bumps a version component up by one. The releaseType parameter specifies the component to be bumped: ReleaseMajor bumps the major version number, ReleaseMinor bumps the minor version number, ReleasePatch bumps the patch version number. The returned string is the new version and the error is nil if bumping was successful.

func Compare

func Compare(left string, right string) (int, error)

Compare compares two versions. It returns: - 0 if both versions are equal - -1 if `left` version is older than `right` version - 1 if `left` version is newer than `right` version Note: `Compare` only compares the major, minor, and patch version numbers. It does not support comparison of build numbers or pre-release labels such as alpha, beta, etc.

func Format

func Format(input string) (string, error)

Format formats the version string into a Semantic Versioning (SemVer) string format. If the input string is not a valid version, an error is returned. The function returns the formatted version string without a v prefix.

func FulfillsConstraint

func FulfillsConstraint(version string, constraint string) bool

FulfillsConstraint checks if the given `version` fulfills the `constraint`. It returns `true` if `version` satisfies the constraints specified in `constraint`, and `false` otherwise. `constraint` should be a string that follows the format described in the semver 2.0.0 specification. Example constraint strings: ">=1.2.3", "^1.2.3", "2.0.0".

func IsStable

func IsStable(input string) bool

IsStable checks if the input is a stable semver version

func IsValidSemver

func IsValidSemver(input string) bool

IsValidSemver checks that the given input is a valid semver version

Types

type ReleaseType

type ReleaseType int32
const (
	ReleaseNone  ReleaseType = 0
	ReleasePatch ReleaseType = 1
	ReleaseMinor ReleaseType = 2
	ReleaseMajor ReleaseType = 3
)

func HighestReleaseType

func HighestReleaseType(numbers []ReleaseType) ReleaseType

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL