/
View dependency graph
Depends on
- dh-golang (dh-golang)
- golang-defaults (golang-any)
- golang-testify (golang-github-stretchr-testify-dev)
- debhelper-compat
README (full)
go-apk-version
A Go library for parsing apk package versions
go-apk-version is a library for parsing and comparing versions
The implementation is based on this implementation
OS: Alpine
Installation and Usage
Installation can be done with a normal go get:
$ go get github.com/knqyf263/go-apk-version
Version Parsing and Comparison
import "github.com/knqyf263/go-apk-version"
v1, err := version.NewVersion("1.2.3")
v2, err := version.NewVersion("1.2.3-r1")
// Comparison example. You can use GreaterThan and Equal as well.
if v1.LessThan(v2) {
fmt.Printf("%s is less than %s", v1, v2)
}
Version Sorting
raw := []string{"1.2.3", "1.2.3_alpha1", "1.2.3-r1", "1.2.4", "1.0_p9-r0"}
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])
})
Contribute
- fork a repository: github.com/knqyf263/go-apk-version to github.com/you/repo
- get original code:
go get github.com/knqyf263/go-apk-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
License
Apache License 2.0
Author
Teppei Fukuda
| dir | .github/ |
| dir | debian/ |
| file | .gitignore |
| file | LICENSE |
| file | README.md |
| file | go.mod |
| file | go.sum |
| file | version.data |
| file | version.go |
| file | version_test.go |
| file | version_testcase.go |