Categorygithub.com/foxcapades/gVersion
repository
1.0.0
Repository: https://github.com/foxcapades/gversion.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

= gVersion

image:https://img.shields.io/github/v/tag/foxcapades/gVersion[GitHub tag (latest SemVer)] image:https://img.shields.io/github/go-mod/go-version/foxcapades/gVersion[GitHub go.mod Go version] image:https://img.shields.io/github/license/foxcapades/gVersion[GitHub] image:https://img.shields.io/badge/api-docs-ff69b4[title="API Docs", link=https://pkg.go.dev/github.com/foxcapades/gVersion/v1/pkg/semver] image:https://github.com/Foxcapades/gVersion/workflows/Go/badge.svg[Go] image:https://codecov.io/gh/Foxcapades/gVersion/branch/main/graph/badge.svg?token=E4WD9IURJL[title=codecov, link=https://codecov.io/gh/Foxcapades/gVersion]

A simple version string representation/parser for dealing with version strings as their individual components.

Additionally, this library imports no stdlib packages apart from unsafe.

.Example [source, go]

func ExampleParse() { version := "v1.23.0-alpha+b58"

ver, _ := semver.Parse(version)

fmt.Println(ver.Major)
fmt.Println(ver.Minor)
fmt.Println(ver.Patch)
fmt.Println(ver.Prerelease)
fmt.Println(ver.Build)

// Output:
// 1
// 23
// 0
// [alpha]
// [b58]

}

Version types are comparable using the methods Equal, Equivalent, IsBefore, and IsAfter.

Equal vs Equivalent

The Equal method compares all components of 2 Version structs, including the prerelease and build tags.

The Equivalent method compares 2 Version structs following the semantic versioning rule that gives 1.0.0 and 1.0.0+b23 the same precedence in version ordering.