goevr is a NEVRA library written in golang for comparing rpm/dpkg package version. Documentation is here.
You can use this library for comparing different rpm/dpkg package versions
package main
import (
"github.com/arzonus/goevr"
"log"
)
func main() {
oldVersion := "6.0-16+deb8u2"
newVersion := "0:6.0-17+deb7u2"
if goevr.GT(newVersion, oldVersion) {
log.Println(newVersion, "greater than", oldVersion )
} else {
log.Println(newVersion, "less or equal than", oldVersion)
}
newEvr := goevr.New(newVersion)
oldEvr := goevr.New(oldVersion)
if newEvr.GTE(oldEvr) {
log.Println(newEvr.String(), "greater or equal than", oldEvr.String())
} else {
log.Println(newEvr.String(), "less than", oldEvr.String())
}
e, v, r := goevr.Parse(oldVersion)
log.Println(e, v, r)
}
go get github.com/arzonus/goevr