A Go library for parsing package versions
go-deb-version is a library for parsing and comparing versions
Versions used with go-deb-version must follow deb-version (ex. 2:6.0-9ubuntu1)
The implementation is based on Debian Policy Manual
OS: Debian, Ubnutu
Installation can be done with a normal go get:
$ go get github.com/knqyf263/go-deb-version
import "github.com/knqyf263/go-deb-version"
v1, err := version.NewVersion("2:6.0-9")
v2, err := version.NewVersion("2:6.0-9ubuntu1")
// Comparison example. There is also GreaterThan, Equal.
if v1.LessThan(v2) {
fmt.Printf("%s is less than %s", v1, v2)
}
raw := []string{"7.4.052-1ubuntu3.1", "7.4.052-1ubuntu3", "7.1-022+1ubuntu1", "7.1.291-1", "7.3.000+hg~ee53a39d5896-1"}
vs := make([]version.Version, len(raw))
for i, r := range raw {
v, _ := version.NewVersion(r)
vs[i] = v
}
sort.Slice(vs, func(i, j int) bool {
return vs[i].LessThan(vs[j])
})
- fork a repository: github.com/knqyf263/go-deb-version to github.com/you/repo
- get original code:
go get github.com/knqyf263/go-deb-version
- work on original code
- add remote to your repo: git remote add myfork https://github.com/you/repo.git
- push your changes: git push myfork
- create a new Pull Request
MIT
Teppei Fukuda