https://github.com/foxcapades/gversion
Version parsing
https://github.com/foxcapades/gversion
Last synced: over 1 year ago
JSON representation
Version parsing
- Host: GitHub
- URL: https://github.com/foxcapades/gversion
- Owner: Foxcapades
- License: mit
- Created: 2020-12-11T03:45:32.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2020-12-11T03:55:25.000Z (over 5 years ago)
- Last Synced: 2025-02-12T17:19:21.385Z (over 1 year ago)
- Language: Go
- Size: 8.79 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.adoc
- License: LICENSE
Awesome Lists containing this project
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.