https://github.com/lzambarda/vergo
A semantic versioning library for go
https://github.com/lzambarda/vergo
go semver yaml
Last synced: 4 months ago
JSON representation
A semantic versioning library for go
- Host: GitHub
- URL: https://github.com/lzambarda/vergo
- Owner: lzambarda
- License: mit
- Created: 2022-02-11T15:18:27.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-05-13T19:07:59.000Z (about 4 years ago)
- Last Synced: 2023-07-27T22:20:00.044Z (almost 3 years ago)
- Topics: go, semver, yaml
- Language: Go
- Homepage:
- Size: 19.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Semver
Simple library to parse, format, compare and bump versions based on the [semantic versioning guidelines](https://semver.org).
Compatible with YAML through https://github.com/go-yaml/yaml
## Usage
```go
a := vergo.New(1, 2, 3, "")
b, _ := vergo.ParseSemver("v1.2.4")
fmt.Println(a) // 1.2.3
fmt.Println(b) // v1.2.4 preserves the versioning
fmt.Println(a.Before(b)) // true
fmt.Println(a.After(b)) // false
a.Bump(vergo.BumpMajor)
fmt.Println(a) // 2.0.0
fmt.Println(a.Before(b)) // false
fmt.Println(a.After(b)) // true
c := vergo.New(1, 0, 0, "rc1") // or -rc1
_ = c.Bump(vergo.BumpReleaseCandidate) // will error if it is not rc
fmt.Println(c) // 2.0.0-rc2 nil
```
Run it on https://go.dev/play/p/E6EyO2LfjtC
## Semver labels
Vergo has limited support for semver with labels (e.g. `v1.0.0-rc1`).
It can parse any sort of label but can only apply a bump to labels in the form of `rc`.