Semantic versioning support in Go
go get github.com/stobbsm/go-semver
To import use:
import version "github.com/stobbsm/go-semver"
Use the Set method to set the version number. Set takes 5 arguments:
- Major uint
- Minor uint
- Patch uint
- Release string
- Build string
If your version is 1.2.3-alpha+build1
version.Set(1, 2, 3, "alpha", "build1")
Or, to omit release and build versioning,
version.Set(1, 2, 3, "", "")
The Get method returns the version as a string. For the examples above, they would be:
"1.2.3-alpha+build1"
and "1.2.3"
respectively