A library for using semantic versioning in Go.
s, err := semver.NewVersion("1.0.0")
if err != nil {
fmt.Printf("Unable to parse version: %s", err)
}
fmt.Printf("%s", s.String())
// "1.0.0"
s.BumpPatch()
fmt.Printf("%s", s.String())
// "1.0.1"
s.BumpMinor()
fmt.Printf("%s", s.String())
// "1.1.0"
s.BumpMajor()
fmt.Printf("%s", s.String())
// "2.0.0"
s.SetPrerelease("alpha")
fmt.Printf("%s", s.String())
// "2.0.0-alpha.1"
s.BumpPrerelease()
fmt.Printf("%s", s.String())
// "2.0.0-alpha.2"
s.SetMetadata("build")
fmt.Printf("%s", s.String())
// "2.0.0+build.1"
s.BumpBuild()
fmt.Printf("%s", s.String())
// "2.0.0+build.2"
v1, _ := semver.NewVersion("1.0.0")
v2, _ := semver.NewVersion("1.0.1")
v1.LessThan(v2) // true
v1.GreaterThan(v2) // false
v1.Equals(v2) // false
Author: Steve Rude steve@slantview.com